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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Milozebre
Helper V
Helper V

Colors based on parameters

Hello Community, 

 

I hope you are doing well, you and your families. I have a question, I found the beginnings of answers on this forum but I can't seem to do what I would like. Here is the background: I have two parameters: "Year analyzed" and "Comparison Year". As you can see from the diagram, the year of comparison is always the same and the other changes a color for the week, another for Saturday and the other Sunday.

PBIC.png

 

Thank you for your help 

1 ACCEPTED SOLUTION

Hello 

I dont find solution with a measure. 

Anytime I put a legend to see year, its not working anymore.

 

With the measure and if I put the paramter table as legend and not the Year, its working. 

 

Thank you for your help, youre awesome

View solution in original post

10 REPLIES 10
Icey
Community Support
Community Support

Hi @Milozebre ,

 



PBIC.png

 


Is this what you want?

If the visual is Clustered column chart, you can't set conditional formating on it. Conditional formatting applies only to the values of Table or Matrix visuals.

column chart.PNG

So, I'm afraid what you want is not possible currently.

 

 

Best Regards,

Icey

 

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

Hello @Icey , 

 

I can put some contionnal formating on clustered column chart as you see with this measure (see image) : 

Mesure Jourcouleur JOB =
SWITCH(
TRUE();
SELECTEDVALUE(Calendrier[Year]) = 2017;"#B3B3B3";
SELECTEDVALUE(Calendrier[Year]) <>2017;"#A1006B")
 
But when I put year in legend or if i choose 2 year, its not working, i loose the formatting, thats my problem. 
I want to see a color for 2017 and 2018 via the measurement.
Because I would have to have a 2018 and 2019 file.
And in this case, 2018 should be gray and 2019 the other color.
Basically
year min = always gray
max year = custom color.
It works until I put a field in legend
 
Thank you 

Hello 

I dont find solution with a measure. 

Anytime I put a legend to see year, its not working anymore.

 

With the measure and if I put the paramter table as legend and not the Year, its working. 

 

Thank you for your help, youre awesome

Milozebre
Helper V
Helper V

Hello, 

 

I try this measure : 

Mesure Jourcouleur2017 =
SWITCH(
TRUE();
SELECTEDVALUE(Calendrier[Year]) = 2017;"#B3B3B3";
SELECTEDVALUE(Calendrier[Year]) = 2018; "#E3E3E3")
 
Its working, if i choose only year. 
But I need to add a legend (jour)
When i put in legend (see image), i loose my conditionnal formating. 
Is it possible to say in the measure below. 
For year 2017 and for all "jour" for 2017 the color is Gray and for the others years 3 others colors ? 
PBIC.png
amitchandak
Super User
Super User

Check color by rule and color by value

https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting

 

Few examples of measure that can used in color by values after selecting fields

Color Date = if(FIRSTNONBLANK('Date'[date],TODAY()) <today(),"lightgreen","red")

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
Color Year = if(FIRSTNONBLANK('Date'[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK('Date'[Year],2014)>2018,"red","yellow"))

Hello @amitchandak 

 

Thank you for the reply

 

I create a measure like this : 

Mesure Jourcouleur =
SWITCH(
SELECTEDVALUE(Comptage[jour]);
"JOB";"#009AA6";
"Samedi";"#A1006B";
"Dimanche";"#659200")
Its working 
But When i choose 2 years, But when I choose 2 years, it works for both. Now I would like that for the previous year, the color be gray and for the current year, the colors that are in the measure
 
Thank you 

 

 

 

Combine with max year and create one or more combinations

If(max(Table[year]) =2007,
SWITCH(
SELECTEDVALUE(Comptage[jour]);
"JOB";"#009AA6";
"Samedi";"#A1006B";
"Dimanche";"#659200"),
///change the color for another year
SWITCH(
SELECTEDVALUE(Comptage[jour]);
"JOB";"#009AA6";
"Samedi";"#A1006B";
"Dimanche";"#659200") )

 @amitchandak 

 

I try but its not working 

Still have same colors for the 2 years. 

Mariusz
Community Champion
Community Champion

Hi @Milozebre 

 

You can add a  day of the week number column to your date dimension, later use it for conditional formating of you chart as below

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Hello @Mariusz 

 

thank you for the reply. 

As you can see on the chart above, what is gray is the year of analysis ex 2018
and in blue, the year of comparison. Gray can't change.
The analysis year which is a parameter must always be gray and the year of comparison on the basis of days must have the predefined colors.
I wanted to make measurements with Swhith but I don't know how to incorporate the parameters:
Year analyze = "Gray"
If day = "Job" with Year comparison; "Red"
for example

 

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.