Search code examples
powerbidaxmeasure

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


Solution

  • 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