Forum Discussion
NMOORE
Helper II
2 years agoincorrect Total Selected Value alternative
Hi, I need to sum quanities differently depending on my column values. The working example is much more complex with info I cannot share so I have drafted up a basic example using the Table below. ...
- 2 years ago
Hi,
so, leave your first calculation like thisExample = VAR _A =CALCULATE(SUM('Example Table'[Quantity]),FILTER(ALL('Example Table'),'Example Table'[Type] = "Cow"))VAR _B =SUM('Example Table'[Quantity])
RETURNIF(SELECTEDVALUE('Example Table'[Type]) = "Dog" ||SELECTEDVALUE('Example Table'[Type]) = "Donkey",_B / _A,0)Add one more measure:
Example2 =
SUMX(SUMMARIZE('Example Table', 'Example Table'[Type], "Example Correct", 'Example Table'[Example]), [Example Correct])
NMOORE
Helper II
2 years agoHi Olgad,
Thanks again for the above. It solves the issue listed but I didnt distill the complexity of my issue into the example very well.
I'm hoping this might be more in line with my issue. If we use the same measure but using your method of HASONEVALUE there are more cases which need to be involved.
Because I need to Filter ALL on some tables I cannot then make it sum properly. I've been trying to create seperate measures and Sum them just in a total but the SelectedValue always follows.
RETURN
IF(
HASONEVALUE('Example Table'[Type]),
IF(
SELECTEDVALUE('Example Table'[Type]) = "Dog" ||
SELECTEDVALUE('Example Table'[Type]) = "Donkey",
_B / _A,
0
),_B / _A
)
I hope I'm missing something obvious. Let me know if you get the chance?
Thanks
olgad
Resident Rockstar
2 years agoHi,
so, leave your first calculation like this
Example = VAR _A =
CALCULATE(
SUM('Example Table'[Quantity]),
FILTER(
ALL('Example Table'),
'Example Table'[Type] = "Cow")
)
VAR _B =
SUM('Example Table'[Quantity])
RETURN
IF(
SELECTEDVALUE('Example Table'[Type]) = "Dog" ||
SELECTEDVALUE('Example Table'[Type]) = "Donkey",
_B / _A,
0
)
Add one more measure:
Example2 =
SUMX(SUMMARIZE('Example Table', 'Example Table'[Type], "Example Correct", 'Example Table'[Example]), [Example Correct])