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
Super User

@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 !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!