Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
Hello,
I've created a measure to color a bar in a chart based on user selection
Solved! Go to Solution.
Hi @Pbiuserr
You need to create a Year table for the slicer and make this table disconnected from Calendar table.
Then use the following measure
Colors =
VAR _CurrentYear = SELECTEDVALUE('Year'[Year])
RETURN
SWITCH(
TRUE(),
MAX('Calendar'[Year]) = _CurrentYear - 2, "#00d600",
MAX('Calendar'[Year]) = _CurrentYear - 1, "#d60000",
MAX('Calendar'[Year]) = _CurrentYear, "#24297A"
)
I have created a sample. Please download the attachment to see details.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi @Pbiuserr
You need to create a Year table for the slicer and make this table disconnected from Calendar table.
Then use the following measure
Colors =
VAR _CurrentYear = SELECTEDVALUE('Year'[Year])
RETURN
SWITCH(
TRUE(),
MAX('Calendar'[Year]) = _CurrentYear - 2, "#00d600",
MAX('Calendar'[Year]) = _CurrentYear - 1, "#d60000",
MAX('Calendar'[Year]) = _CurrentYear, "#24297A"
)
I have created a sample. Please download the attachment to see details.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
This solution in this thread would help you,
Thanks,
Arul
Can you share more details on how to achieve this? I can't figure it out
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 23 | |
| 21 | |
| 17 | |
| 13 |
| User | Count |
|---|---|
| 58 | |
| 51 | |
| 39 | |
| 29 | |
| 24 |