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
lcdelgado
Helper I
Helper I

How can I change the graphic color depending on the values? Power BI Service

Hello! I have a graph with expiration date, 15,30,60,90 days reminder for documents to be expired, and I want to show the documents by department, year, with color code by the reminders if is 15 days or less = red, if is 30-60 day = yellow and so on. 

lcdelgado_0-1673989678830.png

lcdelgado_1-1673989697864.png

I really appreciate any help!!

6 REPLIES 6
Anonymous
Not applicable

Hi @lcdelgado ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1674019996324.png

(2) We can create a calculated column.

Column = DATEDIFF(TODAY(),'Table'[expiration date],DAY)

(3)We can create a measure.

Measure = SWITCH(TRUE(),
MAX('Table'[Column])>0 && MAX('Table'[Column])<=15,"red",
MAX('Table'[Column])>15 && MAX('Table'[Column])<=30,"yello",
MAX('Table'[Column])>30 && MAX('Table'[Column])<=60,"orange",
MAX('Table'[Column])>60 && MAX('Table'[Column])<=90,"blue",
MAX('Table'[Column])>90,"green",
"black")

(4)Set the conditional formatting as shown in the following figure and then the result is as follows.

Picture1.pngPicture2.pngPicture3.png

Best Regards,

Neeko Tang

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

 

What I have now if there are some expiration dates due and the negative number its giving me error #NUM! , 

 

I was using this formula, nut then it changes all numbers for negatives:

=IF(LEN([Expiration Date])=0,0,IF([Expiration Date]<TODAY(),DATEDIF([Expiration Date],TODAY(),"d"),"-"&DATEDIF([Expiration Date],TODAY(),"d")))

🙄I need help on this 

Anonymous
Not applicable

Hi @lcdelgado ,

 

Please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Thanks for the reply, here is the sample data :

lcdelgado_0-1674136497227.png

 

Hello! Thanks for helping me, the formula is giving me an error: Too many arguments were passed to the Max function. The Maximum argument count for the function is 2 😞

Ok I fix it! 

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 Kudoed Authors