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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
PowerRon
Post Patron
Post Patron

SELECTEDVALUE and multiple selections

Hi,

 

beneath is a measure I wrote that works fine if I make one selection from the slicer 'Channel'

 

Chosen Channel =

VAR _metric_select = SELECTEDVALUE('Channel'[Channel ID])

VAR _nbrA = [Number of Transactions A]

VAR _nbrB = [Number of Transactions B]

VAR _nbrC = [Number of Transactions C]

 

VAR _metric =

SWITCH (

    _metric,

    1,_nbrA,

    2,_nbrB,

    3,_nbrC

)

 

RETURN

_metric

 

But for another requirement it has to work differently.
If I choose 1, the measure has to return _nbrA 
If I choose 1 and 2 , the measure has to return _nbrA + _nbrB 
If I choose 1 and 3 , the measure has to return _nbrA + _nbrC 
If I choose 1, 2 and 3 , the measure has to return _nbrA + _nbrB + _nbrC etc. 

So, multiple selections can be made from the slicer. But If I do that, SELECTEDVALUE returns BLANK().

So, how can I fullfill this requirement?

Thnx in advance
Ron

@MFelix 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @PowerRon 

Based on what you've described, I would suggest something like this using SUMX / VALUES:

 

New Measure =
SUMX (
    VALUES ( 'Channel'[Channel ID] ),
    SWITCH (
        'Channel'[Channel ID],
        1, [Number of Transactions A],
        2, [Number of Transactions B],
        3, [Number of Transactions C]
    )
)

 

This would work for single or multiple selection. Also, I have not declared variables outside SWITCH storing the 3 possible values, which avoid unnecessary evaluation.

 

Does this work as intended?

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
PowerRon
Post Patron
Post Patron

This works @OwenAuger 
Thnx

OwenAuger
Super User
Super User

Hi @PowerRon 

Based on what you've described, I would suggest something like this using SUMX / VALUES:

 

New Measure =
SUMX (
    VALUES ( 'Channel'[Channel ID] ),
    SWITCH (
        'Channel'[Channel ID],
        1, [Number of Transactions A],
        2, [Number of Transactions B],
        3, [Number of Transactions C]
    )
)

 

This would work for single or multiple selection. Also, I have not declared variables outside SWITCH storing the 3 possible values, which avoid unnecessary evaluation.

 

Does this work as intended?

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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