Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be 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

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Conditionally always colour with same color bars no matter what slicer

Hello,

I've created a chart which shows based on user date slicer 3 previous years. So if user select May 2022 then it shows May 2020-2022
I want the every bar to have its own color always. So the smallest number in date always color X (2020), medium color Y (2021), biggest color Z (2022). If user select May 2020 then 2018 - X color, 2019 - Y color, 2020 - Z color

 

Is it something to achieve? Every bar should have separate color (the same) despite the selection

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Pbiuserr ;

1.create a new table as slicer date.

slicer = VALUES('Table'[date])

2.create a flag measure ,then apply it into visual filter.

flag = IF(MAX('Table'[date])<=MAX('slicer'[date])&&YEAR(MAX('Table'[date]))>YEAR(MAX('slicer'[date]))-3,1,0)

vyalanwumsft_0-1652322461680.png

3.create a conditional's measure.

conditional = IF([flag]=1,RANKX(ALLSELECTED('Table'),CALCULATE(YEAR(MAX('Table'[date]))),,ASC,Dense))

4.set condition.

vyalanwumsft_1-1652322552343.png

The final output is shown below:

vyalanwumsft_2-1652322572343.png

vyalanwumsft_3-1652322584764.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Pbiuserr ;

1.create a new table as slicer date.

slicer = VALUES('Table'[date])

2.create a flag measure ,then apply it into visual filter.

flag = IF(MAX('Table'[date])<=MAX('slicer'[date])&&YEAR(MAX('Table'[date]))>YEAR(MAX('slicer'[date]))-3,1,0)

vyalanwumsft_0-1652322461680.png

3.create a conditional's measure.

conditional = IF([flag]=1,RANKX(ALLSELECTED('Table'),CALCULATE(YEAR(MAX('Table'[date]))),,ASC,Dense))

4.set condition.

vyalanwumsft_1-1652322552343.png

The final output is shown below:

vyalanwumsft_2-1652322572343.png

vyalanwumsft_3-1652322584764.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

negi007
Community Champion
Community Champion

@Pbiuserr 

 

you can put the month or year in the legend. so that it will show different color for each year or month 

negi007_0-1652100557266.png

 

thanks,

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Requirement is to have X axis Year-Month like 2020 May etc

negi007
Community Champion
Community Champion

@Pbiuserr create a simple measure like below in your date table or on the date field 

Year_Month = FORMAT('Calendar'[Date].[Date],"YYYY MMM")
 
negi007_0-1652102157753.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Colors change when I change selection

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.