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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
han_rj
Helper IV
Helper IV

Selectedvalue dax to work for multiple options selected in filter

I want to write a dax to calculate discount to apply based on slicer selection [product slicer].
Example when Chair and Sofa are purchases I would like to apply a 12% discount but single selection using selectedvalues works but applying condition on multiple values obtained from the slicer does not.

han_rj_1-1721237270861.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @han_rj 

 

You can try the following methods.

Measure 2 = 
VAR _selectedprod =
    ALLSELECTED ( 'Table'[Product] )
VAR _IntersectCount =
            COUNTROWS ( INTERSECT ( _selectedprod, { "Chair", "Sofa" } ) )
VAR _List1Count = COUNTROWS ( _selectedprod )
VAR _result =
    IF( _IntersectCount =_List1Count && _List1Count > 1,12,
    SWITCH (
        TRUE (),
        SELECTEDVALUE('Table'[Product]) = "Chair", 10,
        SELECTEDVALUE('Table'[Product]) = "Sofa", 20,
        SELECTEDVALUE('Table'[Product]) = "Table", 15,
        20
    ))
RETURN
   _result

Charlottezmsft_0-1721286298924.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

7 REPLIES 7
Anonymous
Not applicable

Hi, @han_rj 

 

You can try the following methods.

Measure:

Measure = 
VAR _selectedprod =
    ALLSELECTED ( 'Table'[Product] )
VAR _IntersectCount =
            COUNTROWS ( INTERSECT ( _selectedprod, { "Chair", "Sofa" } ) )
VAR _List1Count = COUNTROWS ( _selectedprod )
VAR _result =
    SWITCH (
        TRUE (),
        SELECTEDVALUE('Table'[Product]) = "Chair", 10,
        SELECTEDVALUE('Table'[Product]) = "Sofa", 20,
        SELECTEDVALUE('Table'[Product]) = "Table", 15,
        _IntersectCount =_List1Count, 12, 20
    )
RETURN
   _result

Charlottezmsft_0-1721283930929.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

 

Hi @Anonymous , Thank You for checking , The value should be 12 when chair and sofa is selected

han_rj_0-1721285106524.png

 

Anonymous
Not applicable

Hi, @han_rj 

 

You can try the following methods.

Measure 2 = 
VAR _selectedprod =
    ALLSELECTED ( 'Table'[Product] )
VAR _IntersectCount =
            COUNTROWS ( INTERSECT ( _selectedprod, { "Chair", "Sofa" } ) )
VAR _List1Count = COUNTROWS ( _selectedprod )
VAR _result =
    IF( _IntersectCount =_List1Count && _List1Count > 1,12,
    SWITCH (
        TRUE (),
        SELECTEDVALUE('Table'[Product]) = "Chair", 10,
        SELECTEDVALUE('Table'[Product]) = "Sofa", 20,
        SELECTEDVALUE('Table'[Product]) = "Table", 15,
        20
    ))
RETURN
   _result

Charlottezmsft_0-1721286298924.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

Thank You , this helped me

Greg_Deckler
Community Champion
Community Champion

@han_rj Correct, SELECTEDVALUE returns BLANK if there is more than one row returned. You can just grab the values (DISTINCT) in the slicer and use the IN operator.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler , thank you for responding,Tried using distinct in a calculated table, I am missing something please can you correct me.

han_rj_0-1721277731669.png

 

@han_rj Should be something like:

VAR __selected = DISTINCT('Table'[Product])

VAR __result = SWITCH( TRUE(), "Chair" IN __selected, 10, ...



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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