Forum Discussion
Division Measure with special case
- 4 years ago
It's not clear to me what the desired result should be in such a case. Are you trying to calculate an average iterating over the rows of the fact table?
If so, just stick it inside an AVERAGEX.
Preferred Method = AVERAGEX ( 'Fact', SWITCH ( 'Fact'[Risk Status], "On-Risk", [Progress Measure], "Inactive", 0, "Off-Risk", 1 ) )
This is fairly straightforward with a SWITCH.
Preferred Method =
SWITCH (
SELECTEDVALUE ( 'Fact'[Risk Status] ),
"On-Risk", [Progress Measure],
"Inactive", 0,
"Off-Risk", 1
)
Alexis, Thank you for the response. You are correct in that your response works for the problem I described. However, in my in-experience, I did not describe the problem very well.
Good Response
My problem is that I did think about what would happen when this Measure gets used in other areas. For example, when we look at the full dataset, there is also a year. And if we group by that in a Matrix, we don't get the desired result.
Would you happen to know how that could be solved, please?
Btw, if you want, I will mark your previous answer as "Accept as Solution" if you so desire.
Thank you in advance.
George
- AlexisOlson4 years ago
Super User
It's not clear to me what the desired result should be in such a case. Are you trying to calculate an average iterating over the rows of the fact table?
If so, just stick it inside an AVERAGEX.
Preferred Method = AVERAGEX ( 'Fact', SWITCH ( 'Fact'[Risk Status], "On-Risk", [Progress Measure], "Inactive", 0, "Off-Risk", 1 ) )