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
nayan28apr
Helper I
Helper I

How to loop into All Selected values and apply diffferent logics for different values selected !

Hi All,

I have franchise filter on the page. I am showing this information in a line chart which is plotted for Month and Weeks.

 

nayan28apr_0-1617281557716.png

What i want is when franchise is OTHER or NON_COE Other or Contingency, I want to show var u calculation. When other  gets selected than I want to show var w calculation.
The problem comes when multiple selection happenes on this franchise filter. When nothing selected that also causes issue.

 

I have tried below approach when i tried with IN and counting each franchise based calculation in each variables. But that not worked for me.

Test Measure =
var a = ALLSELECTED(SonarSabo[franchise])
var u = DIVIDE([This Month Budget], [Weeks in This Month], 0)
var w = DIVIDE([Weekly Previous Year], [Monthly Previous Year], 1) * [Monthly budget]


Var Contingency = If("Contingency" IN a,
CALCULATE(u,SonarSabo[franchise]="Contingency"),0)
 
Var Other = If("OTHER" IN a,
CALCULATE(u,SonarSabo[franchise]="OTHER"),0)

Var NON_COE_OTHER = If("NON_COE Other" IN a,
CALCULATE(u,SonarSabo[franchise]="NON_COE Other"),0)
 
Var AWM =If("AWM" IN a,
CALCULATE(W,SonarSabo[franchise]="AWM"),0)
 
Var ORTHO =If("AWM" IN a,
CALCULATE(W,SonarSabo[franchise]="ORTHO"),0)
 
Var SPORTS_ENT =If("SPORTS & ENT" IN a,
CALCULATE(W,SonarSabo[franchise]="SPORTS & ENT"),0)

Return
IF(OR(a="",a=BLANK()),w,
Other+NON_COE_OTHER+Contingency+AWM+ORTHO+SPORTS_ENT)






Another work around, I tried with SWITCH as below and it is working well when I restrict user to select only one value, that is single select in filter.

Second Measure =
var a = SELECTEDVALUE(SonarSabo[franchise],"All")
var u =(DIVIDE([QTD Weekly Actual PY (for_phased) (ss)], [QTD Monthly Actual PY (for_phased) (ss)], 1) * [QTD Monthly BUD (for_phased) (ss)])
var w = DIVIDE([QTD Monthly BUD (for_phased) (ss)], [Weeks in Each Month], 0)
Return
SWITCH(a,"All",u,
"Contingency",w,
"NON_COE Other",w,
"OTHER",w,
"AWM",u,
"ORTHO",u,
"SPORTS & ENT",u)



 

Is there a way, based on selected values in a slicer I do calculation differently for different selected value like for Other and AWM selected. I calculate values for Other differently and AWM differently and return summed up numbers.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@nayan28apr , in the first version, can try var like these example and check

 

Var Contingency = If(Countx(filter(SALLSELECTED(SonarSabo[franchise]),SonarSabo[franchise] ="Contingency"),SonarSabo[franchise])+0 >0 ,
CALCULATE(u,SonarSabo[franchise]="Contingency"),0)

View solution in original post

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @nayan28apr ,

 

Please try to do like this.

v-lionel-msft_0-1617859451383.png

 

Best regards,
Lionel Chen

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

@nayan28apr , in the first version, can try var like these example and check

 

Var Contingency = If(Countx(filter(SALLSELECTED(SonarSabo[franchise]),SonarSabo[franchise] ="Contingency"),SonarSabo[franchise])+0 >0 ,
CALCULATE(u,SonarSabo[franchise]="Contingency"),0)

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.