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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
evahohk
Helper I
Helper I

๐ƒ๐ฒ๐ง๐š๐ฆ๐ข๐œ ๐‚๐จ๐ฅ๐จ๐ซ ๐‚๐ก๐š๐ง๐ ๐ž ๐ข๐ง ๐‚๐ก๐š๐ซ๐ญ ๐›๐š๐ฌ๐ž๐ on slicer selection

Hi all,

 

I just created a line and stacked column chart. How can I change the colour of last 2 period selected in slicer which is February 2022 & March 2022 to Purple, the remaining period as yellow ? 

evahohk_1-1657544662300.png

 

 

1 ACCEPTED SOLUTION

Hi,

Thank you for your message.

Sorry that I could not understand your data model, so I changed a little bit like below.

- I created a relationship between two tables.

- I changed the measure for the color condition.

Please check the attached pbix file.

Thank you.

Picture1.png

 

Color condition measure 2: =
VAR _lastdatefromslicer =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            CALCULATE ( SUM ( Summary[CY] ) ) <> BLANK ()
        ),
        'Calendar'[End of Month]
    )
VAR _latestmonthfromslicer =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _lastdatefromslicer ),
        'Calendar'[End of Month]
    )
VAR _priormonthoflatestmonth =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Month] < _latestmonthfromslicer ),
        'Calendar'[End of Month]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Calendar'[End of Month] ) = _latestmonthfromslicer
            || SELECTEDVALUE ( 'Calendar'[End of Month] ) = _priormonthoflatestmonth,
        "#8E3A80",
        "#D3DD82"
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

16 REPLIES 16
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

Please create a measure like below, and select the visualization -> go to  Colors -> fx -> format style = field value -> select this measure.

 

Please check the attache pbix file as well.

 

 

Picture1.png

Picture2.png

 

 

 

Color condition measure: =
VAR _lastdatefromslicer =
    CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
VAR _latestmonthfromslicer =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _lastdatefromslicer ),
        'Calendar'[End of Month]
    )
VAR _priormonthoflatestmonth =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Month] < _latestmonthfromslicer ),
        'Calendar'[End of Month]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Calendar'[End of Month] ) = _latestmonthfromslicer
            || SELECTEDVALUE ( 'Calendar'[End of Month] ) = _priormonthoflatestmonth,
        "Purple",
        "Yellow"
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

There are filters in the graph. 

evahohk_0-1657549566726.png

evahohk_1-1657549580569.png

No fx is showing up after I create the condition measure. 

 

Hi,

Thank you for your message.

Could you please share your sample pbix file's link?
Sorry that I could not see situation that does not show without fx.

Please share your sample pbix file's link, and then I can try to have a look to come up with a more accurate solution.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thanks a lot. 

 

How can I add the colour #8E3A80, #D3DD82 into the color condition measure instead of purple and yellow ? 

Hi,

thank you for your message, and please try the below measure.

 

Color condition measure: =
VAR _lastdatefromslicer =
    CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
VAR _latestmonthfromslicer =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _lastdatefromslicer ),
        'Calendar'[End of Month]
    )
VAR _priormonthoflatestmonth =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Month] < _latestmonthfromslicer ),
        'Calendar'[End of Month]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Calendar'[End of Month] ) = _latestmonthfromslicer
            || SELECTEDVALUE ( 'Calendar'[End of Month] ) = _priormonthoflatestmonth,
        "#8E3A80",
        "#D3DD82"
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

It still didn't work in my file. How can I share the file ? 

HI,

You can share your file's onedrive link, or googledrive link, or dropbox link, for instance.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Please refer to the link for the file. Thanks.

Test A 

I have tried the colour condition measure in summary. But the colour didn't change for the last 2 periods in the graph. 

Hi,

Thank you for your message.

Sorry that I could not understand your data model, so I changed a little bit like below.

- I created a relationship between two tables.

- I changed the measure for the color condition.

Please check the attached pbix file.

Thank you.

Picture1.png

 

Color condition measure 2: =
VAR _lastdatefromslicer =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            CALCULATE ( SUM ( Summary[CY] ) ) <> BLANK ()
        ),
        'Calendar'[End of Month]
    )
VAR _latestmonthfromslicer =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _lastdatefromslicer ),
        'Calendar'[End of Month]
    )
VAR _priormonthoflatestmonth =
    MAXX (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Month] < _latestmonthfromslicer ),
        'Calendar'[End of Month]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Calendar'[End of Month] ) = _latestmonthfromslicer
            || SELECTEDVALUE ( 'Calendar'[End of Month] ) = _priormonthoflatestmonth,
        "#8E3A80",
        "#D3DD82"
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thanks for your help. I tried to copy the color condition measure to my graph. It only shows 1st column is highlighted. 

Test A.1 

evahohk_0-1657657407841.png

Also is it possible to show the list of period instead of using between function ? 

evahohk_1-1657657440287.png

 

Hi,

Thank you for your message.

I am not sure if I understood your question fully, but it is difficult for me to know why your data model is using a different column for the axis on the visualization. Without knowing and fully understanding why the specific column is used for the axis on the visualization, instead of a column from the calendar table, it is quite hard for me to fix the measure. May I ask why the column from the calendar table is not used?


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

evahohk_0-1657671058467.png

Is there a quicker way to change the period from MMMM YYYY to MMM YY ?
Display e.g. Jan 21 Feb 21 etc

@evahohk 
Yes, go to the Data tab and under the column tools ribbon, change the format of the date column to your desired format.

Dhacd_0-1657688926131.png

 

If this post helps, then please consider accepting it as the solution to help the other members find it more quickly.
Regards,

Atma.

 

Thanks. Problem solved. Colour can be displayed now. 

amitchandak
Super User
Super User

@evahohk , Create a measure like this and use in conditional formatting with field value option

 


new measure
var _max = minx(allselected(Date), Date[Date])
var _min = eomonth(_max,-3)+1
return
if(Max(Date[Date]) <= _max && Max('Date'[Date]) >=_min, "Purple", "Yellow")

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for the quick response !

I have added new measure. Then how can I see the changes of the colour in the graph ? 

Also if I know the colour Hex : #B3B7B8, how can I add that into the above formula ? 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.