cancel
Showing results 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

Memorable Member

How to make Qtr Bar chart all Q1 same color and Q2 same color.

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 :-

https://www.dropbox.com/s/bcxgotj4edvdtqe/PBT_V2021_392%20TI_SI_GL%20Qtr%20Q1%20bar%20all%20same%20c...

Paul

2 ACCEPTED SOLUTIONS
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

If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!

Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Memorable Member

Thank you very much for your help , it work fine , apprecaite a lot.

Paul

Super User

Hi Paul,

Didn't my code work?  It produces the results you asked for?

Phil

If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!

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

If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!

Memorable Member

also your code more easy to understand.

Paul

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors