cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rachel_zzzz
Frequent Visitor

Get the values of multi selection from slice and then use in Dax

Hi team, I am not sure if this can be done but I assume we should have a way to do it: 

I have two slices come from the same table: segment slice and Week Slice.  What I want to do is when the user select any week, I have a measure calacute the previous week's order amout. If I chose more than two sengments the measure should calculate the last week's order amount for two segments. 

Rachel_zzzz_0-1631508608153.png

 

the dax measure I have is 

EDW_Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(order[Week_Rank])-1
return
CALCULATE(
count(order[order_num]),
FILTER(all(order),order[Week_Rank]=SelectedWeek_privious && order[CUSTOMER_SEGMENT]=SELECTEDVALUE(order[CUSTOMER_SEGMENT])
)
)
but the problem is the selectedvalue only return 1 value, if I chose more than 2 segments then it will return Blank. Is there any way can modify this  dax measure to get what I want? Thanks so much 🙂
1 ACCEPTED SOLUTION

I have figuered out the right way, just put it here in case others come across the same issue: 

Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(Order[Week_Rank])-1
return
CALCULATE(
count(order[ACCOUNT_NUMBER]),
FILTER(ALLEXCEPT(order,order[CUSTOMER_SEGMENT]), Order[Week_Rank]=SelectedWeek_privious)
)

View solution in original post

4 REPLIES 4
v-caitlyn-mstf
Community Support
Community Support

Hi @Rachel_zzzz ,

 

Glad that you have solved this problem! Could you please mark the correct reply as the standard answer to help the other members find it more quickly.Thank you very much for your kind cooperation!

 

Hope it helps,


Community Support Team _ Caitlyn Yan


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

amitchandak
Super User IV
Super User IV

@Rachel_zzzz , You should prefer the date table, joined to your table. Then all will not disturb youe formula

 

But if CUSTOMER_SEGMENT not independent, it should autmatically filter 

 

Try like

EDW_Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(order[Week_Rank])-1
return
CALCULATE(
count(order[order_num]),
FILTER(all(order),order[Week_Rank]=SelectedWeek_privious && order[CUSTOMER_SEGMENT] in allselected(order[CUSTOMER_SEGMENT])
)
)

 

 

I think this should work

 


EDW_Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(order[Week_Rank])-1
return
CALCULATE(
count(order[order_num]),
FILTER(all(Date),Date[Week_Rank]=SelectedWeek_privious
)
)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

I have figuered out the right way, just put it here in case others come across the same issue: 

Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(Order[Week_Rank])-1
return
CALCULATE(
count(order[ACCOUNT_NUMBER]),
FILTER(ALLEXCEPT(order,order[CUSTOMER_SEGMENT]), Order[Week_Rank]=SelectedWeek_privious)
)

View solution in original post

Hi, I tried the code below and didnt get any luck.  The reason I am not using the date table is becuase my visuals contains few tables which the start dates are differernt, so it is hard to defind the week rank. Is there any other method I could try? thanks advance! 

 EDW_Accounts_PreviousWeek =
var SelectedWeek_privious=SELECTEDVALUE(order[Week_Rank])-1
return
CALCULATE(
count(order[order_num]),
FILTER(all(order),order[Week_Rank]=SelectedWeek_privious && order[CUSTOMER_SEGMENT] in allselected(order[CUSTOMER_SEGMENT])
)
)

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors