Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Titatovenaar2
Advocate II
Advocate II

DAX Conditional Formatting in matrix based on Percentiles per Category

Hi everyone,

 

I would like to change my conditional formatting the following way:

  • Mark the field <Sales_HP> and <Sales_HP%> red, for the Lowest 10% of the <Sales_HP%> field, per <Persona>.
    The <Sales_HP%> fields consists of <Sales_HP> divided by <Sales>.
  • Mark the field <Sales_HP> and <Sales_HP%> orange, for the between 20-30% of the lowest records of the <Sales_HP%> field, per <Persona>.

 

Titatovenaar2_3-1655222177031.png

 

 

As you can see for Persona A, the Lowest 10% of the records in this case is only CustomerID 1, and for Persona B this is CustomerID 20.

 

<Sales>, <Sales_HP> and <Sales_HP%> are all measures.

Is there a way of creating a measure that can be used in the following field:

Titatovenaar2_4-1655222321500.png

using here the <Sales_HP%> measure doesn't yield the right results.

 

Any suggestion on how to do this is appreciated a lot!

 

Kind regards,

Igor

 

1 ACCEPTED SOLUTION
Titatovenaar2
Advocate II
Advocate II

Alright, that gave me an idea though which in the end solved the problem!

Titatovenaar2_0-1655282409185.png


I ranked <Sales_HP%> per Persona first with measure <Rank>

Then I took the maximum <Rank> per persona with measure <Max Rank>

Followed by dividing the <Rank> by <Max Rank> with measure <Rank / Max Rank>

Using those numbers give me the correct Percentiles I am looking for:

 

Rank = 
RANKX ( FILTER( ALL ( Sales ), Sales[Persona] = MAX( Sales[Persona] ) ), Sales[Sales HP%], , ASC )

Max Rank = 
MAXX ( ALLSELECTED ( Sales[CustomerID] ), [Rank] )

Rank / Max Rank = 
DIVIDE(
    [Rank]
    ,[Max Rank]
)

View solution in original post

3 REPLIES 3
Titatovenaar2
Advocate II
Advocate II

Alright, that gave me an idea though which in the end solved the problem!

Titatovenaar2_0-1655282409185.png


I ranked <Sales_HP%> per Persona first with measure <Rank>

Then I took the maximum <Rank> per persona with measure <Max Rank>

Followed by dividing the <Rank> by <Max Rank> with measure <Rank / Max Rank>

Using those numbers give me the correct Percentiles I am looking for:

 

Rank = 
RANKX ( FILTER( ALL ( Sales ), Sales[Persona] = MAX( Sales[Persona] ) ), Sales[Sales HP%], , ASC )

Max Rank = 
MAXX ( ALLSELECTED ( Sales[CustomerID] ), [Rank] )

Rank / Max Rank = 
DIVIDE(
    [Rank]
    ,[Max Rank]
)
PhilipTreacy
Super User
Super User

Hi @Titatovenaar2 

 

Download example PBIX file with the following data and visuals.

 

I'm not following the logic you used to work out the formatting.  If you want the bottom 10% red then shouldn't that be CustomerID's 1, 10, 17 and 20?  They all have Sales HP% values of 10% of less.

 

Regarding the orange values, you state these are for values betwen 20 and 30%.  What about values between 10 and 20%?  I've assumed you meant orange for values between 10 and 30%.

 

cfrule-2.png

 

This is the Conditional Formatting rule I used for both Sales_HP and Sales_HP% (one rule for each)

 

cfrule-1.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil,

Thanks for your reply!

Unfortunately it is not yet what I am looking for. I am not looking for literally the numbers of 0-10% and 10-30%, I am looking for the Lowest 10% percentile Per Persona. Meaning that Only CustomerID 1 with 5% <Sales_HP%> can be coloured RED and CustomerID 10 with 10% should not color red. With 10 records for Persona A, only 1 can be allowed in the 10% lowest percentile group.

 

So I have the idea that it has to include some sort of ranking measure that divides the percentiles, but not sure how to do that.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.