esteebie
esteebie

Reputation: 167

In Power BI, how can you return the category label based on the max value for all categories returned by a measure using DAX?

Looking for some DAX guidance here, to return a text field based on the maximum returned by a measure appplied over that column.

i.e we have table[category_column] and [measure] and the measure references columns in other tables, with two-sided relationships.

Any help much appreciated, very stuck!

Thanks in advance

Upvotes: 1

Views: 12123

Answers (2)

Rob C
Rob C

Reputation: 46

If I'm reading right, I think you want to draw the measure against the column values and return the row with the max of the measure. Something like this?

newMeasure = 
    VAR vals = SUMMARIZE('Table', 'Table'[Column1], "myMeasure", [Measure])
    VAR measureMax = MAXX(vals, [myMeasure])
    VAR value = CALCULATE(MAXX(FILTER(vals, [myMeasure] = measureMax), [Column1]))
RETURN
    value  

Upvotes: 2

CR7SMS
CR7SMS

Reputation: 2584

If your column to be used for max is Column1 and your text field is Column2 something like the below could work:

Measure = 
VAR Max_Value =max('Table'[Column1])
Return CALCULATE(MAX('Table'[column2]),'Table'[Column1]=Max_value)

If this is not what you are looking for you have to explain your requirements in further detail, hopefully with examples.

Upvotes: 0

Related Questions