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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
MChakri
Regular Visitor

Conditional Formatting - Switch Case

Hello Pals,

 

I have a peculiar case with Switch statement as I am unable to apply conditional formatting for a single line item. Lets say, I have 5 line items and calculated against months like JAN, FEB, ...DEC, Q1, Q2, Q3, Q4, YTD etc..,I have a Grand total as 5th line item and that line item need to have a conditional formatting for "-" values. (Identified with a different color instead of default).  

MChakri_0-1686939383252.png

 We would like to see the conditional formatting for Total other Margin and Net Margin should be with different color in Power BI. 

 

MChakri_1-1686939630544.png

Switch statement looks like the above 

10 REPLIES 10
Akshaan
Frequent Visitor

Hi @MChakri you can make this small change to get the desired result.

Akshaan_0-1687147837859.png


Please accept this as solution if it works for you to help others.

Thanks,

Hi @MChakri, This is the answer to the above asked question:

CF =
SWITCH(
    SELECTEDVALUE('New Table'[Report Column]),
    "Other: Audit Accruals/Credits Margin" , IF([JANNEWF]<0, "Red")
)

Here are my observations/suggestions:
1. Use hierarchies instead of calculated column Categorn intern with some additional spaces
2. You derived field i.e. JANNEWF , FEBNEWF should be in Whole Number format instead of text to make this code work.

Pls correct me If I am wrong in above!!Pls correct me If I am wrong in above!!@Akshaan , see this is not working for me. One thing is that this is a derived field !! Pls correct me!

Hi @MChakri , it seems you are not passing the condition for CategoryIntern column in the above measure (line 5 item). Also, can you please explain why are you using 2 different measures in here?
1.  NETMARGIN- YTD

2. OTHER COGS Test


You can share you .pbix frm here.

Akshaan_0-1687154278889.png

 

@Akshaan Unable to send .pbix file as it is only allows .jpeg files only. I tried again but seems no luck. do you have any other mediums to connect?

 

Thanks,

MChakri

MChakri_0-1687282564292.png

 

https://drive.google.com/file/d/1qnaQdb_t7zq6rqZLF_T0ogQGv7VuE7Km/view?usp=sharing  Here you go. Attached with .pbix file.  Let me know if this is doeable. Thanks a ton!!

@Akshaan Any luck on the file sent to you? We can close the discussion if you are ok to help me on last step!! Thanks,

Akshaan
Frequent Visitor

Hi @MChakri, you can achieve this by using a similar dax measure only for a selected dimension ( in your case line 5 item). 

 

Capture.PNG

 

if it doesn't works for you, please share your .pbix file.

@Akshaan Any help is appreciated!! TIA. 

Hi @Akshaan, Is this possible for only negative values...This should work if we have any negative values in the "Net Margin" column alone. Apologies for my late response.. Wanted to share the .pbix file but I don't see an option to do so. 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors