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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vasubabu
Frequent Visitor

Conditional Formatting

Hi,

 

Seems like the formatting is not working as expected and need your inputs.

Sample Data format for last months.

vasubabu_1-1753245086061.png

 

Based on the above data, I wanted to display sales per store for the last N months and highlight with a color if there is a drop/increase in the qty for each mont based on ..

If current-previous month >0 then "Green" color Ex: 4092 > 1506

If  current-previous month <0 then "Red" color Ex: 1623 < 4092

IF current-previous month =0 then "Black" color Ex: 999=999(not in data)

vasubabu_8-1753247204263.png

 

 

Created the dashboard for the last 6 months and applied conditonal formating.

vasubabu_0-1753245046024.png

 

However When I adjust the slicer value—for example, to “Last 5 months”—the formatting no longer applied  as intended. Expected 3010 as red color but showing as green.

vasubabu_5-1753245507694.png

 

Expected Output:

vasubabu_4-1753245355485.png

 

When I choose last 4 months the output shown as : but expected output is 1506 and 4067 numbers should be in red color.

vasubabu_6-1753245574491.png

Output:

vasubabu_7-1753245644053.png

 

Link for data and pbix file:

https://www.dropbox.com/scl/fo/x78r3g299b9v3r0dkxnxf/ALzapb6qt_XQNbwgxKqLYHM?rlkey=zu6sqsjgy212p0gx7...

9 REPLIES 9
v-sgandrathi
Community Support
Community Support

Hi @vasubabu,

 

I wanted to check if you had the opportunity to review the information provided by super users @alish_b @Ashish_Mathur @Irwan  and @danextian. Please feel free to contact us if you have any further questions

Thank you and continue using Microsoft Fabric Community Forum..

vasubabu
Frequent Visitor

@danextian , @Ashish_Mathur , @Irwan  Updated the inital post as per the sample dataset and also attached the pbix file. Pls check.

Hi,

If you drag the previous month measure to your visual, you will see that there is no figure for 03/2025 (because you have chosen to show only the pat 5 months).  Since 3010 > 0, it appears in green.  That seems OK.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur  Technically that is correct but my usecase is to consider immediate previous month(if available in db) though the month is not part of date slicer or not displaying in the chart. Please let me know if there is any work around.

 

If this is not possible, then can u let me know in displaying the last N months(lowest month) only in black color rather than green color.. As 3010>0.

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1753358969153.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @vasubabu ,
I tweaked the Previous Month qty measure as follows:

Previous Month qty = 
CALCULATE([total_qty], PREVIOUSMONTH(DateTable[Date]), ALL(DateTable))
Basically, this is altering the filter context of date that is applied to the measure. 
Also, I changed the Date Slicer to have DateTable[Date] in the Field section instead of the order_date.

alish_b_1-1753332783604.png

alish_b_2-1753332866044.png

Also, one more important thing, I found a weird behavior in the relative date slicer in the report file (I wonder if it was just on my machine and won't be replicated on yours) that it wouldn't slice properly when I added a simple table with just DateTable[Date] as Columns. It also caused the above solution to not behave as expected. (It took me for a wild goose chase and I started questioning the universe) Anyway, I deleted the slicer and added a new one and it worked as expected.

Hope it helps!

danextian
Super User
Super User

Hi @vasubabu 

The relative date slicer is based on the current system date, not the last date in your semantic model. Also, I noticed you're using my usual sample file  - I'm curious what changes you made, since your conditional formatting isn't working. Did you make sure the Dates table is has been marked as such? Also, when debugging it is best to show the measures involve and not just the measure the conditional formatting is applied to so you or people will know which one could be causing the problem.

danextian_0-1753243481695.png

danextian_1-1753243656112.png

danextian_2-1753243691572.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Please explain your requirement in simple langage.  Share the download link of the PBI file.  Show the expected result there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Irwan
Super User
Super User

hello @vasubabu 

 

i am not sure how your data looks like but it seems to me the conditional formating only for values.

There is no conditional formating for date therefor changing date slicer will not have any effect on conditional formating.

 

otherwise, please share your sample data that represent your original data (remove any confidential information) including with your expected/desired result.

you can upload your pbix in online storage like dropbox, etc.

 

Thank you.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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