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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

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-xiaoyan-msft
Community Support
Community Support

Hi @Anonymous ,

 

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

@Anonymous , 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
)
)

Anonymous
Not applicable

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)
)
Anonymous
Not applicable

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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