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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Replace value based on slicer

Hi All!

 

I have two slicers in my report "Haulier" and "Show hide name". What i need is the following:

 

If "Show hide name" is set to Hide and a a Haulier is chosen then the report should show all the halier names as "Haulier" except the name for the haulier selected.

 

If "Show hide name" is set to Show all the haulier names should be shown.

 

Any idea how can i do that? 

 

OscarDom_0-1651514870322.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's my solution.

1.Add an index column into your table visual. If there is no index column, it is likely to affect the rendering of the data. For example, the same percentage may only appear once.

You can directly add an index column in Power Query, or add an index column by group. Reference: Create Row Number for Each Group in Power BI using Power Query - RADACAD

vstephenmsft_0-1651719728157.png

 

2.There's no relationship among tables.

vstephenmsft_1-1651719868760.png

 

3.Create a measure to return the different results.

Measure =
SWITCH (
    SELECTEDVALUE ( 'Slicer2'[Show/Hide Name] ),
    "Hide",
        IF (
            SELECTEDVALUE ( Slicer[Hauliers] ) = MAX ( 'Table'[Hauliers] ),
            MAX ( 'Table'[Hauliers] ),
            "Haulier"
        ),
    "Show", MAX ( 'Table'[Hauliers] )
)

 

Here is the output:

When 'Hide' and 'C' are selected,

vstephenmsft_2-1651720013041.png

When 'Show' and 'C' are selected,

vstephenmsft_4-1651720169118.png

 

Best Regards,

Stephen Tao

 

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

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's my solution.

1.Add an index column into your table visual. If there is no index column, it is likely to affect the rendering of the data. For example, the same percentage may only appear once.

You can directly add an index column in Power Query, or add an index column by group. Reference: Create Row Number for Each Group in Power BI using Power Query - RADACAD

vstephenmsft_0-1651719728157.png

 

2.There's no relationship among tables.

vstephenmsft_1-1651719868760.png

 

3.Create a measure to return the different results.

Measure =
SWITCH (
    SELECTEDVALUE ( 'Slicer2'[Show/Hide Name] ),
    "Hide",
        IF (
            SELECTEDVALUE ( Slicer[Hauliers] ) = MAX ( 'Table'[Hauliers] ),
            MAX ( 'Table'[Hauliers] ),
            "Haulier"
        ),
    "Show", MAX ( 'Table'[Hauliers] )
)

 

Here is the output:

When 'Hide' and 'C' are selected,

vstephenmsft_2-1651720013041.png

When 'Show' and 'C' are selected,

vstephenmsft_4-1651720169118.png

 

Best Regards,

Stephen Tao

 

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

 

Anonymous
Not applicable

@Anonymous Thank you a lot. It worked for me.

amitchandak
Super User
Super User

@Anonymous , The haulier needs to be an independent slicer

 

haulier = distinct(Table[haulier]) // New table

 

meausre =

var _tab = allselected(haulier[haulier])

return

Switch( selectedvalues('ShowHide'[ShowHide])  ,

"Show", calculate([YesPercent Meaure], filter(Table, Table[haulier] in _tab) ) ,

calculate([YesPercent Meaure], filter(Table, not Table[haulier] in _tab) )

)

 

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors