Search code examples
powerbidaxpowerquerydata-analysispowerbi-desktop

Power BI: The lowest value between two columns


is there a possibility to find the lowest value between two columns in Power BI?

This is the table:

Name Maths Physics
Emma 73.2 32.5
Theo 95.3 76.5
Ellen 52.7 99.7

I have to get a card that would in this case show Emma because if we compare both exams, the worst result got Emma from Physics.

Preferably, the card would say Emma 32.5, but Emma is fine, too.

My research:

these two ways give a good result, but only for one column:

First:

MinResult = CALCULATE(MIN(results(Name),TOPN(1,'results',results[Maths],ASC))

Second:

MinResult = 
    CALCULATE(
        MIN(results(Name),
        results[Maths] = MIN(results[Maths])
    )

Solution

  • You were close. You can add an expression to the TOPN.

    MinResult =
      CALCULATE(
        MIN(results[Name]),
        TOPN(1, 'results', MIN([Maths], [Physics]), ASC)
      )
    

    And with score:

    MinResult = 
      CALCULATE(
        MIN(results[Name]) & " " & MIN( MIN(results[Maths]), MIN(results[Physics]) ),
        TOPN(1, 'results', MIN([Maths], [Physics]), ASC)
      )
    

    You may want to consider whether Unpivoting your table in PowerQuery would be more useful:

    enter image description here