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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Hayoung
Helper IV
Helper IV

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?

CaptureWER.PNG

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Hayoung ,

 

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.

RicoZhou_0-1663744908440.png

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

RicoZhou_1-1663745131498.png

Result is as below.

RicoZhou_2-1663745241689.png


Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

lbendlin
Super User
Super 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-...
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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors