Returning true for multiple select in a slicer

Hi,

The idea is to return true when i select multiple items from a filter. Here goes the sample dax which is working for single select but somehow not working for multiselect.

Variation 1
Measure_Multiselect
if(
SELECTEDVALUE(‘Sales’[Customer Group Code (Lookup)]) in {“VE”,“TZ”},TRUE(),FALSE()
)

Variation 2
Measure_Multiselect
if(
OR(SELECTEDVALUE(‘Sales’[Customer Group Code (Lookup)]) = “VE”,SELECTEDVALUE(‘Sales’[Customer Group Code (Lookup)]) =“TZ”),
TRUE(),FALSE()
)

Variation 3
Measure_Multiselect
if(
SELECTEDVALUE(‘Sales’[Customer Group Code (Lookup)]) = “VE”,True(),If(SELECTEDVALUE(‘Sales’[Customer Group Code (Lookup)]) =“TZ”,TRUE(),FALSE()
))

So, who is up for some dax exercise. Also, Is there any way we can harvest filter selections placed at page level?

Best Regards,
Hemant

Hi @Hemantsingh,

I hope you have DAX Studio installed…if not you can find it here: https://daxstudio.org/
Connect to your model, right click on the table name and choose: Define Filter Dump Measure

image

I hope this is helpful.

For this you can refer:

For the measure you could try something like this:

Measure =
IF (
    CALCULATE (
        COUNTROWS ( VALUES ( Products[Color] ) ),
        KEEPFILTERS ( Products[Color] IN { "Blue", "Black" } )
    ) >= 2,
    TRUE (),
    FALSE ()
)

Here’s SQLBI’s writeup on displaying the filter dump in a tooltip.

Hope this help.
Greg

Thanks @Greg

Hi @Greg, @Melissa @AntrikshSharma,

Thanks for replies.

Antriksh reply is very close to what i want to do. Somehow, I cannot use antriksh approach coz the measure i am trying to create is a conditional measure. I should have given the full calculation context in the first post itself.

The logic is:-
if a certain set of values are selected in a slicer than apply one kind of measure and if other set of values are applied then apply some other measure. The conditional measure i wrote is working fine when only one value is selected in the slicer but when more than 1 value is selected it is returning blank for obvious reasons as selectedvalue returns only one value else blank.

@AntrikshSharma The reason why your measure didn’t work because it fails to keep the filter context coming from other different dimensions due to use of calculate ( I am not 100% sure here).

here is the measure i have edited using @AntrikshSharma approach

Plan Unit Revenue (Conditional) =
SWITCH (
    TRUE (),
    CALCULATE (
        COUNTROWS ( VALUES ( 'Sales'[Customer Group Code (Lookup)] ) ),
        KEEPFILTERS ( 'Sales'[Customer Group Code (Lookup)] IN { "VE", "TZ" } )
    ) >= 2, [Plan Unit Revenue (SVL)],
    SELECTEDVALUE ( 'Sales'[Group] ) = "VE", [Plan Unit Revenue (VE)]
)

@AntrikshSharma As i said in my initial post i am trying to check for 2 values checked/selected simultaneously for ‘Sales’[Customer Group Code (Lookup)] column used as slicer and when it do so i would like to use [Plan Unit Revenue (SVL)] measure.
In other part of switch i am checking for a value on a different column and accordingly using a different measure.

Further, Thanks for posting about the dumping measure tooltip however i am already using it and i must say it is a very useful piece of DAX code. I am also an avid follower of SQLBI guys.

Regards,
Hemant

Hi @Hemantsingh, please be sure to check out our DAX Clean Up tool it’s a great way to ensure to make your DAX code easy to read. Thanks!