Forum Discussion

raviteja1994's avatar
raviteja1994
Regular Visitor
8 years ago
Solved

DAX Create measure with multiple aggregations over 2 columns

Hello,

 

I am trying to create a DAX measure with following table.

 

Column AColumn BColumn CDateValue
11P110/26/201710
11P110/27/201720
13P310/28/201710
22P110/29/201715
22P210/30/201725


I want to dislpay the following grid data. 

Column AColumn B Value
1120
1310
2240

 

The measure is calculated as follows:  It is a 2 step aggregation

Get the max value for each of the first 3 column values. i.e after the 1st aggregation the result would look like:

Column AColumn B Column CValue
11P120
13P310
22P115
22P225

 

Now sum it over first 2 columns to get the final result which is:

 

Column AColumn B Value
1120
1310
2240

 

Help me in creating the DAX measure which would result in the above data when I create a table visual in Power BI.  Thanks in advance..

  • raviteja1994

    You can try

    sum =
    VAR first_agg_tbl =
        SUMMARIZE (
            yourTable,
            yourTable[Column C],
            "Max of each column C", MAX ( yourTable[Value] )
        )
    RETURN
        SUMX ( first_agg_tbl, [Max of each column C] )
    

2 Replies

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    raviteja1994

    You can try

    sum =
    VAR first_agg_tbl =
        SUMMARIZE (
            yourTable,
            yourTable[Column C],
            "Max of each column C", MAX ( yourTable[Value] )
        )
    RETURN
        SUMX ( first_agg_tbl, [Max of each column C] )