Forum Discussion
COLOR BOX FOR LEGEND THAT SHOW %
Do anyone know how to show the percentage based on the data with specific color box like the photo?
3 Replies
- lbendlinSuper User
Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - AnonymousNot applicable
Hi Anonymous ,
Accoridng to your statement, I suggest you to try conditonal formatting.
For reference: Apply conditional table formatting in Power BI - Power BI | Microsoft Learn
Here I create a sample to have a test.
Measure:
Percentage = VAR _Value = CALCULATE ( SUM ( 'Table'[Value] ) ) VAR _Total = CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table' ) ) RETURN DIVIDE ( _Value, _Total )Color = VAR _RANK = RANKX(ALL('Table'),[Percentage],,DESC,Dense) RETURN SWITCH(_RANK,1,"Green",2,"Yellow","Red")Format your visual > Cell elements > Series [Percentage]>Background
Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
May be i need to clarify something. The green color not meaning the largest percentage. The color must be in this order not matter the percenatge is, which mean it could be 1% for the green color and 98% for the red color.