Forum Discussion

nayan28apr's avatar
nayan28apr
Icon for Helper I rankHelper I
5 years ago
Solved

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.

 

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.

  • 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)

2 Replies