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
chotu27
Post Patron
Post Patron

replacing column values based on slicer slection

 

Sample data:

CategoryDatamaskingValues
Intensive Caresub367
Laon Caresub123
Medical Caresub235

 

 

 

 

 

Output required:   Suppose user selects Loancare from category slicer Output  column should be shown as below same for all the Category values in slicer.Capture 2.PNG

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @chotu27

I build a table like yours to have test.

1.png

We need to build a new Slicer table by Category column.

Slicer = VALUES('Table'[Category])

 

Then build a slicer.

Build a measure to achieve your goal.

Output =

VAR _selectvalue =

    SELECTEDVALUE ( 'Slicer'[Category] )

RETURN

    IF (

        MAX ( 'Table'[Category] ) = _selectvalue,

        MAX ( 'Table'[Category] ),

        CALCULATE (

            MAX ( 'Table'[Datamasking] ),

            FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )

        )

    )

 

Result:

Default:

2.png

Select Laon Care:

3.png

You can download the pbix file from this link: Replacing column values based on slicer slection

 

Best Regards,

Rico Zhou

 

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

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @chotu27

I build a table like yours to have test.

1.png

We need to build a new Slicer table by Category column.

Slicer = VALUES('Table'[Category])

 

Then build a slicer.

Build a measure to achieve your goal.

Output =

VAR _selectvalue =

    SELECTEDVALUE ( 'Slicer'[Category] )

RETURN

    IF (

        MAX ( 'Table'[Category] ) = _selectvalue,

        MAX ( 'Table'[Category] ),

        CALCULATE (

            MAX ( 'Table'[Datamasking] ),

            FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )

        )

    )

 

Result:

Default:

2.png

Select Laon Care:

3.png

You can download the pbix file from this link: Replacing column values based on slicer slection

 

Best Regards,

Rico Zhou

 

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

@v-rzhou-msft @Greg_Deckler 

 

Can i Use Output Measure DAX in calculated column instead, beacause i wanted to use this column in some charts as legend

 

 

 

Thanks

Hi @chotu27 

I build a new measure to you and you can display multiple values selected in output.

 

Output = 
VAR _selectvalue =
    ALLSELECTED ( 'Slicer'[Category] )
VAR _DateMasking =
    CALCULATE (
        MAX ( 'Table'[Datamasking] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )
    )
RETURN
    IF (
        ISFILTERED ( Slicer[Category] ),
        IF (
            MAX ( 'Table'[Category] ) IN _selectvalue,
            MAX ( 'Table'[Category] ),
            _DateMasking
        ),
        _DateMasking
    )

 

You can use Ctrl+left click the box to select the multiple value.

Result:

1.png

And if you want to remove Datamasking column from table visual, you need to make value column not summarize.

2.png

Result:

3.png

Calculated column can not show dynamic values like measure, but a measure can't be added into the legend.

I try to build a matrix visual to work like a legend.

You need to add color in conditional formatting and change the column header's and Grid 's color to white.

4.png

Result:

5.png

You can download the pbix file from this link: replacing column values based on slicer slection

 

Best Regards,

Rico Zhou

 

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

@v-rzhou-msft  Thank you for your help i have a small questions 

 Q1 :  If i remove Datamasking column from table it is not showing me the same results.

 Q2:   What if the user selects multiple values from slicer ? is there any possibilty to display multiple values selected in output?

Greg_Deckler
Super User
Super User

@chotu27 - Not quite following this. 

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

That said, this might help: https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-EVERYTHING-measures-axis-legend-titl...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  Can you check now

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.