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


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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/...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview. ✨
️ November 12th-14th, 2024
 Online Event
Register Here

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