Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Conditional formatting using percentiles in a matrix

Hello,

 

I was wondering how I could use conditional formatting in a matrix using percentiles for a measure. So, I have a measure broken up by a few dozen people in a matrix. I want the top 25% of these people (in terms of this measure) to be one color, the next 25% to be a different color, and so on.

 

I've included a picture of what I'm talking about. I just have a regular color scale here, but I want my measure, PPH, to be colored by each quartile as I explained above. Any ideas?

 

 

Thanks

  • Anonymous's avatar
    Anonymous
    6 years ago

    kentyler Ahhh I see, thanks for the suggestion! I just realized however that I need to be able to change the values of PPH with a date filter, so I have a slicer on my main page which changes the dates I pull my PPH data from, and thus changes PPH. The date range and thus PPH need to be able to be changed at will. You did however give me some good ideas as to how to move forward, so thank you!

9 Replies

  • kentyler's avatar
    kentyler
    Solution Sage

    There are 2 functions for calculating the percentile of a value, PERCENTILE.EXC and PERCENTILE.INC. According to a post I found "

     both of these formula exclude one number from your series.

    1. inc includes first number of the series and excludes last number.
    2. Exc excludes first number of series and includes last number."

    I created a calculated column using both measures and got a result of 1,2,3,4 for each value. Unfortunately 

     
     
    PPHQuartile_INCQuartile_EXC
    2.8411
    2.9311
    3.1911
    3.2411
    3.3422
    3.4822
    3.522
    3.5733
    3.833
    3.8233
    4.0443
    4.5344
    4.7144
    6.1544
       

    you can see that in one case 4.04 comes out 3 and in the other 4. You will have to decide whether to use INC or EXC

    Here are the 2 calculated columns

    Quartile_EXC = VAR QUARTILE_1 = PERCENTILE.EXC(Sheet1[PPH],.25)
    VAR QUARTILE_2 = PERCENTILE.EXC(Sheet1[PPH],.5)
    VAR QUARTILE_3 = PERCENTILE.EXC(Sheet1[PPH],.75)
    VAR CURpph = Sheet1[PPH]
    VAR RETURNVAL = IF(CURPPH <= QUARTILE_1,1,IF(CURPPH <= QUARTILE_2,2,IF(CURPPH<=QUARTILE_3,3,IF(CURPPH>QUARTILE_3,4))))
    RETURN RETURNVAL
     
    Quartile_INC = VAR QUARTILE_1 = PERCENTILE.INC(Sheet1[PPH],.25)
    VAR QUARTILE_2 = PERCENTILE.INC(Sheet1[PPH],.5)
    VAR QUARTILE_3 = PERCENTILE.INC(Sheet1[PPH],.75)
    VAR CURpph = Sheet1[PPH]
    VAR RETURNVAL = IF(CURPPH <= QUARTILE_1,1,IF(CURPPH <= QUARTILE_2,2,IF(CURPPH<=QUARTILE_3,3,IF(CURPPH>QUARTILE_3,4))))
    RETURN RETURNVAL
     
    there are the same except for the function used
    You can use the conditional formatting of cells in a column to change the color based on the 1,2,3,4 value

    • Anonymous's avatar
      Anonymous
      Not applicable

      kentyler Thank you very much for your reply. However, PPH in my case is a measure, not a column in a sheet. What can I do in this case?

      • kentyler's avatar
        kentyler
        Solution Sage

        If you can post the text of the measure, I think I can show you how to incorporate it.