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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Snagalapur
Helper IV
Helper IV

Conditional colour format Bar chart

Hi All,

 

Please suggest measure to combine multiple statements of conditional colour format into one, currently my bar chart toggle between 3 options using slicer.

 

How to use single condition to colour bars when toggle between slicer options?

IF(TABLE[Act v. LY (Top 10 Bar chart)] < 1, "#FF0000", "#00CC66")

IF(TABLE[Act v. Bud (Top 10 Bar chart)] < 1, "#FF0000", "#00CC66")

IF(TABLE[Act v. Fcst (Top 10 Bar chart)] < 1, "#FF0000", "#00CC66")

 

 

Measures:
Act v. Bud (Top 10 Bar chart) =  SUM('Table'[actual])- SUM('Table'[budget])

Field paramater: 

KPI's = {
     ("Act v. Bud"NAMEOF('MEASURES_TABLE'[Act v. Bud (Top 10 Bar chart)]), 0),
    ("Act v. Fcst"NAMEOF('MEASURES_TABLE'[Act v. Fcst (Top 10 Bar chart)]), 1),
    ("Act v. LY"NAMEOF('MEASURES_TABLE'[Act v. LY (Top 10 Bar chart)]), 2)
   }

Snagalapur_2-1742382631647.png

Snagalapur_3-1742382654017.png

 

 

1 ACCEPTED SOLUTION



Hi @Snagalapur 

Thank you for reaching out to the Microsoft Fabric Forum Community.

Can you try below DAX


Bar Chart Color Format =
VAR SelectedKPI = SELECTEDVALUE('KPI''s'[KPI's]) -- This refers to the field parameter slicer
VAR KPIValue =
SWITCH(
SelectedKPI,
"Act v. Bud", [Act v. Bud (Top 10 Bar chart)],
"Act v. Fcst", [Act v. Fcst (Top 10 Bar chart)],
"Act v. LY", [Act v. LY (Top 10 Bar chart)],
BLANK()
)
RETURN
IF(KPIValue < 1, "#FF0000", "#00CC66")



If this information is helpful, please “Accept as solution”  to assist other community members in resolving similar issues more efficiently.
Thank you.



View solution in original post

7 REPLIES 7
v-priyankata
Community Support
Community Support

Hi @Snagalapur 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

bhanu_gautam
Super User
Super User

@Snagalapur , You can create a measure using SWITCH

DAX
ColorMeasure =
SWITCH(
TRUE(),
SELECTEDVALUE(Slicer[Selection]) = "Act v. LY" && TABLE[Act v. LY (Top 10 Bar chart)] < 1, "#FF0000",
SELECTEDVALUE(Slicer[Selection]) = "Act v. LY" && TABLE[Act v. LY (Top 10 Bar chart)] >= 1, "#00CC66",
SELECTEDVALUE(Slicer[Selection]) = "Act v. Bud" && TABLE[Act v. Bud (Top 10 Bar chart)] < 1, "#FF0000",
SELECTEDVALUE(Slicer[Selection]) = "Act v. Bud" && TABLE[Act v. Bud (Top 10 Bar chart)] >= 1, "#00CC66",
SELECTEDVALUE(Slicer[Selection]) = "Act v. Fcst" && TABLE[Act v. Fcst (Top 10 Bar chart)] < 1, "#FF0000",
SELECTEDVALUE(Slicer[Selection]) = "Act v. Fcst" && TABLE[Act v. Fcst (Top 10 Bar chart)] >= 1, "#00CC66",
"#000000" // Default color if none of the conditions are met
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you for details. currently i'm facing below error , could you please suggest, currently i'm using calculated measures in slicer as parameters.

Snagalapur_1-1742384371329.png

 

 

 

Anonymous
Not applicable

Please share some sample data and show which fields are placed in the bar chart and in the field parameter?

Hi Please find details of fields used in chart.

Measures:
Act v. Bud (Top 10 Bar chart) =  SUM('Table'[actual])- SUM('Table'[budget])
Act v. LY (Top 10 Bar chart) =  SUM('Table'[actual])- SUM('Table'[LY])
Act v. Fcst (Top 10 Bar chart) =  SUM('Table'[actual])- SUM('Table'[Fcst])

Field paramater: 

KPI's = {
     ("Act v. Bud"NAMEOF('MEASURES_TABLE'[Act v. Bud (Top 10 Bar chart)]), 0),
    ("Act v. Fcst"NAMEOF('MEASURES_TABLE'[Act v. Fcst (Top 10 Bar chart)]), 1),
    ("Act v. LY"NAMEOF('MEASURES_TABLE'[Act v. LY (Top 10 Bar chart)]), 2)
   }

Snagalapur_0-1742896217562.png

 

Snagalapur_1-1742896217506.png

 

 



Hi @Snagalapur 

Thank you for reaching out to the Microsoft Fabric Forum Community.

Can you try below DAX


Bar Chart Color Format =
VAR SelectedKPI = SELECTEDVALUE('KPI''s'[KPI's]) -- This refers to the field parameter slicer
VAR KPIValue =
SWITCH(
SelectedKPI,
"Act v. Bud", [Act v. Bud (Top 10 Bar chart)],
"Act v. Fcst", [Act v. Fcst (Top 10 Bar chart)],
"Act v. LY", [Act v. LY (Top 10 Bar chart)],
BLANK()
)
RETURN
IF(KPIValue < 1, "#FF0000", "#00CC66")



If this information is helpful, please “Accept as solution”  to assist other community members in resolving similar issues more efficiently.
Thank you.



Hi

I hope the information provided was helpful. If you still have questions, please don't hesitate to reach out to the community.
Thanks.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.