Forum Discussion
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.
Thank you for your help
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
10 Replies
- MariuszCommunity Champion
- MilozebreHelper V
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
- amitchandakSuper 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"))- MilozebreHelper V
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 workingBut 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 measureThank you- amitchandakSuper User
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") )
- MilozebreHelper 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 ? - IceyCommunity Support
Hi Milozebre ,
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.
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.
- MilozebreHelper V
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 legendThank you- MilozebreHelper V
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