Forum Discussion
incorrect Total Selected Value alternative
- 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])
Hi,
I dont know if it is gonna fit your real example,
but here it is
- NMOORE2 years ago
Helper II
Thanks so much Olgad, just away from my work at the moment I'll give it a whirl on Monday. Cheers
- NMOORE2 years ago
Helper II
Hi 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.
RETURNIF(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
- olgad2 years ago
Resident Rockstar
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])
- NMOORE2 years ago
Helper II
Much appreciated thanks. I've used Summarize to create tables in my data models but not wrapped inside SUMX like that so a very useful piece of learning, it worked in the large working model.
I tried to add the Example2 code as a RETURN - referencing Example as a variable (so it was all in the same measure) but the total was in the billions? I was looking at a neat way to put it all in one measusure but obviously not essential.
Thanks again