March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi All
I have a Qtr bar chart , i like to make all Q1 bar same color . i have try measure , i get error :-
color by qtr = Switch(max('Date'[year]),
Q1, "green",
Q2, "blue",
Q3, "red",
Q4"grey"
)
My PBI file :-
Paul
Solved! Go to Solution.
Hi Paul,
This code works
color by qtr =
VAR __Qtr = SELECTEDVALUE('Date'[Year Quarter])
RETURN
SWITCH(
TRUE(),
CONTAINSSTRING(__Qtr, "Q1"), "green",
CONTAINSSTRING(__Qtr, "Q2"), "blue",
CONTAINSSTRING(__Qtr, "Q3"), "red",
"gray"
)
Regards
Phil
Proud to be a Super User!
Hi @admin11 ,
Please update the formula of measure [color by qtr] as below:
color by qtr =
SWITCH (
RIGHT ( SELECTEDVALUE ( 'Date'[yrqtr] ), 2 ),
"1Q", "Green",
"2Q", "Blue",
"3Q", "Red",
"4Q", "Grey"
)
Best Regards
Hi @admin11 ,
Please update the formula of measure [color by qtr] as below:
color by qtr =
SWITCH (
RIGHT ( SELECTEDVALUE ( 'Date'[yrqtr] ), 2 ),
"1Q", "Green",
"2Q", "Blue",
"3Q", "Red",
"4Q", "Grey"
)
Best Regards
Hi Paul,
Didn't my code work? It produces the results you asked for?
Phil
Proud to be a Super User!
Hi Paul,
This code works
color by qtr =
VAR __Qtr = SELECTEDVALUE('Date'[Year Quarter])
RETURN
SWITCH(
TRUE(),
CONTAINSSTRING(__Qtr, "Q1"), "green",
CONTAINSSTRING(__Qtr, "Q2"), "blue",
CONTAINSSTRING(__Qtr, "Q3"), "red",
"gray"
)
Regards
Phil
Proud to be a Super User!
I am sorry , i miss your reply. i just tested your is working fine.
also your code more easy to understand.
Paul
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
90 | |
88 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
70 | |
68 |