0

In the NReco examples there is a section on derived dimensions based on other dimensions. Is there a way to to a derived dimension based on a measure?

NReco derived dimension from another dimension example below

Define derived dimension expand hierarchy It is possible to define derived dimension (= calculated from existing dimension key or keys) in the following way:

var pvtData = new PivotData(new[]{ "creation_date", ... }, ... );
var byMonthCube = new SliceQuery(pvtData).Dimension("creation_date_month",
    (dimKeys) => {  // array of entry dimension keys
        var creationDateValue = (DateTime)dimKeys[0]; // #0 - index of "creation_date" dimension
        return creationDateValue.Month;
    }
);
var byYearAndQuarter = new SliceQuery(pvtData).Dimension("creation_date_year_and_quarter",
    (dimKeys) => {
        var creationDateValue = (DateTime)dimKeys[0]; // #0 - index of "creation_date" dimension
        return String.Format("{0} Q{1}", 
            creationDateValue.Year, GetQuarter(creationDateValue.Month) );
    }
);

Example layout

Jason
  • 13
  • 3

1 Answers1

0

In terms of OLAP, how dimension can be based on measure at all?.. For example, let's assume that we're talking about multidimensional dataset with 2 dimensions and 1 measure that is represented as a collection of (d1,d2)->(m) pairs. This data may be visualized as a pivot table where rows are formed by d1 values and columns by d2 values; for each row x column intersection we can place measure m value.

It is unclear, how a pivot table with dimension based on m could look like here (and what is a practical sense of this). Maybe you mean derived measure? When you define a new measure with a formula that is calculated by another collected measures.

Vitaliy Fedorchenko
  • 8,447
  • 3
  • 37
  • 34
  • Sorry maybe my question wasn't clear or maybe not possible. I am looking to use the output of a cube that has calculated a measure based dimensions but then use it to categorize the data. I can't fit it in this comment so I added an image to the post of the data coming out of the cube now and what I want to turn it into. – Jason Sep 16 '19 at 18:21
  • @Jason image doesn't help much to understand what exactly you want to calculate. Term "prev" gives assumption that calculation depends on the *pivot table* structure (if this is true, you cannot perform this calculation on PivotData class level b/c this is multidimensional dataset, it doesn't represent pivot table structure and doesn't know what is 'prev' or 'next'). Then, if this is calculation on IPivotTable level, you cannot define new dimensions - because new dimension affects pivot table structure, isn't it?.. – Vitaliy Fedorchenko Sep 17 '19 at 07:02
  • @Jason it is essential to clarify that you cannot define a dimension that is not derived from anything (I mean formal relationship here). If your input data doesn't have dimension(s) that identify "New", "Churn", "Increase" etc groups - you cannot add this dimension later! This is not technical, this is conceptual limitation. Your input data should be in the form that allows to identify these groups *by dimensions*. – Vitaliy Fedorchenko Sep 17 '19 at 07:09