Forum Discussion

Nethergate's avatar
Nethergate
New Member
4 years ago
Solved

Max by category

Hi guys,

 

I have the data set below which has duplicated Cost center headcount records due to multiple Account Type.

 

Can you advise which Dax formula I can use to get to the desired outcome column (screenshote below) based on the categories in peach column (By Country, By Cost Center, By Month)?

 

 

 

Editable version

CountryCost CenterMonthAccountHeadcount by cost centerDesired outcome
AustraliaAJanpayroll11
AustraliaAJanbonus1 
AustraliaAJanOvertime1 
AustraliaBJanOvertime22
AustraliaBJanbonus2 
AustraliaBJanPayroll2 
AustraliaAFebbonus44
AustraliaAFebPayroll4 
AustraliaAFebOvertime4 

 

  • Nethergate , You need to add an index column in the power query and then try this DAX new column

     


    var _min = minx(filter(Table, [Country] =earlier([Country]) && [Cost Center] =earlier([cost Center]) && [Month] =earlier([Month])), [Index])
    var _max = maxx(filter(Table, [Country] =earlier([Country]) && [Cost Center] =earlier([cost Center]) && [Month] =earlier([Month])), [headcount])
    return
    if([Index] =_min, _max, blank())

3 Replies

      • amitchandak's avatar
        amitchandak
        Super User

        Nethergate , You need to add an index column in the power query and then try this DAX new column

         


        var _min = minx(filter(Table, [Country] =earlier([Country]) && [Cost Center] =earlier([cost Center]) && [Month] =earlier([Month])), [Index])
        var _max = maxx(filter(Table, [Country] =earlier([Country]) && [Cost Center] =earlier([cost Center]) && [Month] =earlier([Month])), [headcount])
        return
        if([Index] =_min, _max, blank())