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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hasharma19
Helper II
Helper II

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 section haveing same topic twice, then topice show highligted in RED, else in black.

I have created view, but only challange here if i am selecting location from slicer and there is multple topic in section column then result showing in RED, but as soon slecting multiple value or selecting all it is also considering all value and showing in RED., whereas i want it calculte based on selection, if selected location have same topic in section colum then show in red else default or in case multiple location selected also show as deafult color(black).

hasharma19_0-1668449221209.png

hasharma19_5-1668449538759.png

 

Measures that i have used

hasharma19_2-1668412883022.pnghasharma19_3-1668412896111.png

View without selectio or all selected which i want as Black

hasharma19_4-1668449475997.png

 

View to single selected location and its correct.

hasharma19_3-1668449442057.png

 

1 ACCEPTED SOLUTION

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" )

1.PNG

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

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @hasharma19,

You can try to use the following measure formal to get the row count of current facility based on selection values:

formula =
VAR currFacility =
    SELECTEDVALUE ( Table[Facility] )
VAR summary =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( Table ), [Section] IN VALUES ( Table[Section] ) ),
        [Facility],
        [Section],
        "SC", COUNT ( Table[Section] )
    )
RETURN
    COUNTROWS ( FILTER ( summary, [Facility] = currFacility && [SC] > 1 ) )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,Thanks for your time 

i have tried using provide DAX, it is visual in black.

conditional formatting not working.

 

Hi @hasharma19,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,

Please find the data

Result needed, if in section(highlighted column) same topic will come for any particular location so that the value should be highligt in Red while selecting through slicer and in case none of location slected or multiple location selected resulted shold be default(value in black color)

 

Sr No.DateRegionFacilityReview Question #SectionRemarksGAPLevelStatusClosure DateSubmitted OnYearColumn
113-Feb-22NorthDEL NOY05-04-2022Minimum requirements - WarehouseDG & LiBa StickersGAP1Level1Close14-02-202214-10-2022 14:16:1220222
220-Jan-22NorthDEL RPO01-04-2022Minimum requirements - WarehouseDG labels & Incompatibility posterGAP1Level1Close31-01-202214-10-2022 14:18:3720222
318-Jan-22NorthDEL FDB03-01-2022GeneralTest & Certificates not availableGAP1Level1Close28-01-202214-10-2022 14:22:1320222
431-Jan-22SouthBLR BG1 Emergency Procedures - ReportingBG1 facility not tagged in RCIRGAP1Level1Close10-02-202214-10-2022 14:24:0020223
508-Jan-22SouthMAA EGM02-10-2022Emergency Procedures - ReportingEmergency Contact Numbers not visibleGAP1Level1Close18-01-202214-10-2022 14:25:3820223
621-Jan-22SouthBLR HSR01-04-2022Minimum requirements - WarehouseDG labels & Incompatibility posterGAP1Level1Close02-02-202214-10-2022 14:29:2420222
721-Jan-22SouthBLR HSR02-10-2022Emergency Procedures - ReportingEmergency Contact DetailsGAP2Level1Close02-02-202214-10-2022 14:33:2820223
809-Feb-22SouthMAA GYO Road OperationsCAT 12 Training for X Ray ScreenerGAP1Level1Close19-02-202214-10-2022 14:35:3420221
909-Feb-22SouthMAA GYO Load Control and Ramp ProceduresTo nominate at least one SVC Supervisor for CAT-6GAP2Level1Close19-02-202214-10-2022 14:36:5220221
1009-Feb-22SouthMAA GYO Acceptance & Handling ProceduresDG acceptance sticker & LiBA. Both stickers are mixedGAP3Level1Close19-02-202214-10-2022 14:39:4820221
1115-Jan-22WestBOM VSO Minimum Training RequirementsCAT 6 validity expiredGAP1Level1Close25-01-202214-10-2022 14:43:5220221
1215-Feb-22WestBOM MPT06-01-2022GeneralCAT 4,5,7 Training Pending for 3 StaffGAP1Level1Close25-02-202214-10-2022 14:46:1220222
1315-Feb-22WestBOM MPT SLAs/ContractsCAT 4,5,7 Training Pending for 3 StaffGAP2Level1Close25-02-202214-10-2022 14:49:4220221
1415-Feb-21WestBOM MPT06-01-2022GeneralCAT 4,5,7 Training Pending for 3 StaffGAP2Level1Close20-08-202128-10-2022 14:16:5720212

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" )

1.PNG

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

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.