Forum Discussion

hasharma19's avatar
hasharma19
Helper II
3 years ago
Solved

Conditional Formatting based on Slicer

Hello Everyone, I need help in conditional formatting based on Slicer in Power BI. Having a small dataset(mostly text formatted) and want to show the data in Table like, if i slect location and if ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    HI hasharma19,

    You can use the following measure formula at 'conditional formatting' ->'font color' with 'field value' mode to setting color formatting based current Facility and Section:

    Colorcode =
    VAR currFacility =
        SELECTEDVALUE ( 'Table'[Facility] )
    VAR currSection =
        SELECTEDVALUE ( 'Table'[Section] )
    VAR summary =
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            [Facility],
            [Section],
            "SC", COUNT ( 'Table'[Section] )
        )
    VAR rowCount =
        COUNTROWS (
            FILTER (
                summary,
                [Facility] = currFacility
                    && [Section] = currSection
                    && [SC] > 1
            )
        )
    RETURN
        IF ( rowCount > 0, "Red", "Black" )

    Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

    Regards,

    Xiaoxin Sheng