Forum Discussion
Context transition with variable
- 4 years ago
mgrayTCB try this:
MS Months Chg2 = AVERAGEX ( FILTER ( ADDCOLUMNS ( Project, "@datechg", VAR SSdate = CALCULATE ( MINX ( MilestoneSS, MilestoneSS[DateActOrEstSS] ) ) VAR Curdate = CALCULATE ( MAXX ( Milestones, Milestones[DateActOrEst] ) ) VAR datechg = DATEDIFF ( SSdate, Curdate, DAY ) / 30.4 RETURN datechg ), [@datechg] <> 0 ), [@datechg] )
Hi:
I beleive it's due to having multiple iterators with calculate.
Would somehing like this work?
CombinedMeasure = IF([MS Months Chg]<>0, [MS Months Change], BLANK())
the combined measure that is not working is the one with the variable datechg. I tried that if statement there but it does not help. Any other ideas?
- Whitewater1004 years agoSolution Sage
Hi:
If you have sample data it will be easier to try to solve. Thank you.
- mgrayTCB4 years agoHelper IV
See the sample data here
https://drive.google.com/file/d/1F-60fTrgFjDy53ycBb7uqlwDEjcNleP1/view?usp=sharing
Why does the two step measure approch provide the correct average while the AllInOneMeasure does not.
- Whitewater1004 years agoSolution Sage
Hi:
I did not see Milestones field? I have updated a few things but not traking on the measures you mentioned regarding Milestones.
https://drive.google.com/file/d/1PhhAyK-UJO7xWJocDYgh3VhzM4X-_hM9/view?usp=sharing
Both FILTER & the X functions are iterators. When used together with calculate you can get unexpected results. The second iterator has another row context vs first iterator.
Note - I know you are looking for average differences. Is this for just for months with data or by month even though there is no data?
Thanks..