Forum Discussion

varshahrame's avatar
varshahrame
Frequent Visitor
5 years ago
Solved

MIN MAX

I have seen a lot of MIN and MAX formulas out there but they do not seem to work with the data I have. I have a table called BR Overhead which holds individual value fields, such as below 

 

 

I cannot for the life of me how to write a formula to highlight the MIN and MAX in this table.

 

Any suggestions?

 

 

 

11 Replies

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    Hi varshahrame -

     

    It may be messy, but you'll probably have to nest MAX/MIN for each field you want compared

     

    MAX( MAX( MAX( MAX( DEPR_AMOUNT, INS_BLDG), MAG), PHONE), REP_MAINT_EQ)

     

    etc

     

    Hope this helps

    David

     

  • varshahrame's avatar
    varshahrame
    Frequent Visitor

    So I did try this and it allowed me to choose my first field but it wouldnt let me select the 2nd field....it was showing as grayed out.

     

     

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    You need to put an aggregation on each field. If you're just looking at a single row each time, you can use SUM and it will give you the same value.

     

    MAX( MAX( SUM(ColA), SUM(ColB) ), SUM(ColC) ) etc

    • varshahrame's avatar
      varshahrame
      Frequent Visitor

      Yayyyy thank you so much!!!! On to my next question...from the detail below, how can i have the field that has that max value highlighted. So in this example I would like the field 'RENT" to be highlighted as thats the MAX value.

       

      I truly appreciate your help. I am so new to Power BI and I am still finding my way.

       

       

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    varshahrame - unfortunately, conditional formatting like you are going for operates on a column, not on a row, at least to my knowledge. If you were to "transpose" the table to be a list of attributes and values, then it may be possible, but Pivot/Transpose is not available in DAX (again, to my knowledge).

     

    I'll see if I can bring others into this thread that may have ideas.

     

    David

    • DataZoe's avatar
      DataZoe
      Microsoft Employee

      dedelman_clng varshahrame If you really don't want to unpivot your data, you can create a measure to find the the Max Value, which I think you have done, then create a measure per column that will check to see if it's the Max Value and then use that to conditionally format the background or however you want to format it.

       

       

      I've attached the PBIX as well.  Hope this helps.

      • varshahrame's avatar
        varshahrame
        Frequent Visitor

        Thank you so much DataZoe! This worked perfectly. The only issue is having to do this for ALL other columns! haha....but it works, so I am happy about that.

         

        APPRECIATE EVERYONES HELP!

    • varshahrame's avatar
      varshahrame
      Frequent Visitor

      That is what I was afraid of, everything I had been reading was talking about columns as opposed to rows and then I did come across a few articles that did say to transpose the data in order to do the conditional formatting.

       

      Thank you!

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    You need to unpivot the table in Power Query to get the Min/Max