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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

ALLSELECTED not working with multiple selected values.

I have a table with online order data. Here is a sample:

 

Order_nbr, Item_nbr, channel, prod_cost, prod_cost_packaging

1              ,  2           , Pickup  , 10           , 0.4 

2              ,  7           , Delivery, 10           , 0.4 

3              ,  8           , Vendor  , 10           , 0.4 

 

 

I am creating a metric which will contain prod_cost or prod_cost_packing based on channel, such as for Pickup, it displays prod_cost_packaging, for Delivery, it displays prod_cost and for Vendor, it displays prod_cost_packaing. 

 

I have a slicer on the channel field of the table, I would like to display the sum of all selected channels (whether packaging or prod_cost with respect to channel) for 2 or more selections. 

 

My code (below) works when slicing for 1 channel, but not when I select 2 or more. 

 

var Flowpath_choice = ALLSELECTED(Table[Channel])

return

SWITCH(
    TRUE(),
    [Flowpath_choice] in {"Delivery"}, CALCULATE([Actual Amount]),
    [Flowpath_choice] in {"Pickup","Vendor"}, CALCULATE([Package Amount]),
    0
    )
 
 
I'm new to power bi and DAX so this might just be from not understanding what allselected does; if there is an alternative solution to this problem then that'd be much appreciated as well.
 
This is the error I'm getting. 
pbierrall.PNG
 
All help is appreciated.
3 REPLIES 3
Anonymous
Not applicable

.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below.

 

Expected result measure: =
VAR Flowpath_choice =
    SELECTEDVALUE ( Table[Channel] )
RETURN
    SWITCH (
        TRUE (),
        Flowpath_choice IN { "Delivery" }, [Actual Amount],
        Flowpath_choice IN { "Pickup", "Vendor" }, [Package Amount],
        0
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

This gets rid of the error. But this isn't an actual solution. I have a slicer on the channel field for the table; when I select 2 or more channels, the measure should display the sum of all channel costs (whether packaging or prod_cost). The above solution gets rid of the error but doesn't support the actual multiple selection of the channels. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.