Forum Discussion

maciabit's avatar
maciabit
Frequent Visitor
2 years ago
Solved

Help! Best by category dinamically using DAX (.pbix attached)

Hello everyone!

 

I am asking for your help because, despite searching, I cannot find a way to create this DAX function. I uploaded here a .PBIX FILE EXAMPLE.
Simplified version of the problem follows.


I'm in this situation: 

 

 

 And want to obtain this:

 

 

I have a table containing store, category and a mymeasure (a measure).

For each category I need to find the best store. The calculation of the best store must be dynamic on the selected month, but must not consider any filters on the category or store.

I was able to calculate the value the best measure of that category. This is how i made value_highest_in_category:

 

value_highest_in_category =
CALCULATE(
    MAXX(
        SUMMARIZE('Data', 'Data'[store], "myMeasure", [measure]), [measure]
    ),
    ALLEXCEPT('Data','Data'[month]), 'Data'[category] = MAX('Data'[category])
)

 

but I just can't extract the name of the corresponding store.

I thank anyone who can help me!

  • Measure 2 = VAR _vm=[value_highest_in_category] RETURN MAXX(FILTER(ALL(Data[store]),[measure]=_vm),'Data'[store])

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Icon for Community Champion rankCommunity Champion
    Measure 2 = VAR _vm=[value_highest_in_category] RETURN MAXX(FILTER(ALL(Data[store]),[measure]=_vm),'Data'[store])