Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Conditional formatting for values in a Matrix visual based on the date

Hello,

 

I am currently trying to create a matrix visual where each column is a month and have the conditional formatting shade certain values in based on the month they are in. Eg. for this visual I have posted a screenshot of, I would like all coumns, or the column headers, to all be shaded for the months after october.

 

All help is appreciated,

Thanks.

 

4 Replies

  • Anonymous , As of now, you can not do conditional formatting on row/column of Matrix

     

    For values, you can have. Create a color measure and use that in conditional formatting using field value option

     

    Colour =
    SWITCH(TRUE(),
    'Table'[Date] < TODAY(), "red",
    'Table'[Date] = TODAY(), "orange",
    "green")

     

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for your reply, when trying to use this formula, it cannot use my date table or the columns in it. Do you know why this would happen?

     

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi Anonymous ,

     

    The conditional format is applied to the values that satisfy the condition, and the corresponding column names do not apply.

    M = IF(MONTH(MAX('Table'[Date]))>MONTH(TODAY()),"grey","white")

     

    For more details, you can read below blog:

    Power BI Conditional Formatting: The Ultimate How-To Guide (hevodata.com)


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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

  • Anonymous's avatar
    Anonymous
    Not applicable

    That solution is viable, however the solution I found worked best was ranking the months and adding the condition that way as so:

     

    Eg.

    Conditionalformatting =
    Var selectedmonth = SELECTEDVALUE('DateTable'[Date (bins)])
    Var ranktable = ALLSELECTED('DateTable'[Date (bins)])
    Var Productrank =
    RANKX(ranktable, 'DateTable'[Date (bins)], selectedmonth)
    Var CF = if(Productrank < 7, "Light blue")
    Return CF
     
    Thank you for youre response