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
ak1207
New Member

To get slicer selected values as a list to put it under IN ()

Hi ,

How can we get selected list of values from slicer in {"val_1","val_2","val_3"} format, so that the list can be put under IN () operator ?

 

Currently using a measure,

Measure = (CONCATENATEX ( VALUES ( Values_Column[Values]),[Values] , ",")) and getting val_1,val_2,val_3 as value but not able to use under IN() operator.
 
TIA.
1 ACCEPTED SOLUTION
v-jialluo-msft
Community Support
Community Support

Hi @ak1207 ,

 

Please follow these steps:

(1) Create a new measure

FLAG = 
IF (
    ISFILTERED ( Slicer_Table[Col_2] ),
    IF (
        MAX ( 'Table 1'[Col_1] )
            IN EXCEPT (
                SUMMARIZE (
                    FILTER ( 'Table 1', [Col_2] IN VALUES ( Slicer_Table[Col_2] ) ),
                    [Col_1]
                ),
                SUMMARIZE (
                    FILTER (
                        ALL ( 'Table 1' ),
                        NOT ( [Col_2] ) IN VALUES ( 'Slicer_Table'[Col_2] )
                    ),
                    [Col_1]
                )
            ),
        1
    )
)

(2) Add filtering

vjialluomsft_0-1669704537362.png

 

(3)Final output

vjialluomsft_1-1669704537363.png

 

vjialluomsft_2-1669704537363.png

 

vjialluomsft_3-1669704537363.png

 

Best Regards,

Gallen Luo

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

4 REPLIES 4
v-jialluo-msft
Community Support
Community Support

Hi @ak1207 ,

 

Please follow these steps:

(1) Create a new measure

FLAG = 
IF (
    ISFILTERED ( Slicer_Table[Col_2] ),
    IF (
        MAX ( 'Table 1'[Col_1] )
            IN EXCEPT (
                SUMMARIZE (
                    FILTER ( 'Table 1', [Col_2] IN VALUES ( Slicer_Table[Col_2] ) ),
                    [Col_1]
                ),
                SUMMARIZE (
                    FILTER (
                        ALL ( 'Table 1' ),
                        NOT ( [Col_2] ) IN VALUES ( 'Slicer_Table'[Col_2] )
                    ),
                    [Col_1]
                )
            ),
        1
    )
)

(2) Add filtering

vjialluomsft_0-1669704537362.png

 

(3)Final output

vjialluomsft_1-1669704537363.png

 

vjialluomsft_2-1669704537363.png

 

vjialluomsft_3-1669704537363.png

 

Best Regards,

Gallen Luo

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

Thanks @v-jialluo-msft for the solution. 🙂

amitchandak
Super User
Super User

@ak1207 , In case you are more than one selected then you can use in values(Table[values])

 

example

filter(Table, Table[Value] in values(Table[Values]))

Thanks @amitchandak for the response. However, the solution provided in not working for me.

Please find below problem exploration with the usecase/example :

 

Table 1 
Col_1Col_2
A1
B1
B2
C1
C2
C3
D1

 

Slicer_Table
Col_2
1
2
3

 

If selected value(s), from slicer, only the Col_1 data which belong to the selected value and NOT anything else should display.

 

View : Table with Table_1[Col_1] vs Measure and a slicer with Slicer_Table[Col_2]

 

For example,

if selected 1, only A & D should show

if selected 2, no one should show (since 2 mapped to B & C but they belong to other Col_2 data as well)

if selected 1 & 2, A,B & D should show

if selected 1,2 & 3 ; All should show

 

WORKING WITH HARDCODED VALUE 1 & 2 ::

Measure_x = 

CALCULATE (
    DISTINCTCOUNT(Table_1[Co1_1]),
    FILTER(VALUES (Table_1[Col_1]),
    CALCULATE ( DISTINCTCOUNT (Table_1[Col_2 ]), not(Table_1[Col_2]) in {"1","2"}  ) = 0
    )
)
 
NOT WORKING WITH slicer selected VALUE 1 & 2 ::

Measure_y= 

CALCULATE (
    DISTINCTCOUNT(Table_1[Co1_1]),
    FILTER(VALUES (Table_1[Col_1]),
    CALCULATE ( DISTINCTCOUNT (Table_1[Col_2 ]), not(Table_1[Col_2]) in VALUES(Slicer_Table[Col_2])  ) = 0
    )
)
 
Please help with the above example.

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.

Top Solution Authors