Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
How can I have different colours for different years in a chart visual? I have tried a switch measure but when I go to the Conditional formatting option on the visual, the measure I just made does not load, I just get a "blank" red outlined box;
The calculation I used for the measure was;
Colour scheme = SWITCH(true(), max('Calendar'[Year])="2022","pink",
max('Calendar'[Year])="2023", "purple",
max('Calendar'[Year])="2024", "orange","silver")
Or am I going about this the wrong way?
Thank you in advance.
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but if the year column in the calendar table is not text format, please try something like below.
Colour scheme =
SWITCH (
TRUE (),
MAX ( 'Calendar'[Year] ) = 2022, "pink",
MAX ( 'Calendar'[Year] ) = 2023, "purple",
MAX ( 'Calendar'[Year] ) = 2024, "orange",
"silver"
)
Hi @Jaqinthebox ,
Thank you for @Jihwan_Kim and @_AAndrade answer , and I have other suggestions:
Below is my table:
The following DAX might work for you:
Colour scheme =
SWITCH(true(),
MAX('Table'[Date]) = "1/1/2024","pink",
MAX('Table'[Date])="2/1/2024", "purple",
MAX('Table'[Date])="3/1/2024", "orange","silver")
The final output is shown in the following figure:
What we can see is that this metric is applied well in the table, indicating that there is no problem, on the bar chart the x-axis fails, which is an existing problem.
There is currently no way to control the x-axis of the bars via measure.
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you all for your replies @Anonymous @Jihwan_Kim @_AAndrade
It was the reply from @Jihwan_Kim which helped. I hadn't formatted the "Year" column in my calendar to Text. I had no idea that had to be done for conditional formatting measures to work (I'm relatively new to Power BI!)
Result as below;
Thanks again to everyone that replied.
Hi,
I am not sure how your semantic model looks like, but if the year column in the calendar table is not text format, please try something like below.
Colour scheme =
SWITCH (
TRUE (),
MAX ( 'Calendar'[Year] ) = 2022, "pink",
MAX ( 'Calendar'[Year] ) = 2023, "purple",
MAX ( 'Calendar'[Year] ) = 2024, "orange",
"silver"
)
Did you try to click on that box and search for your measure?
Proud to be a Super User!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 68 | |
| 33 | |
| 31 | |
| 31 |