Forum Discussion

NMOORE's avatar
NMOORE
Icon for Helper II rankHelper II
2 years ago
Solved

incorrect 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. ...
  • olgad's avatar
    olgad
    2 years ago

    Hi, 

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