Forum Discussion

charleshale's avatar
charleshale
Continued Contributor
3 years ago
Solved

Totalling selected values

Let's say I have a table named FRUIT that looks like this:   TYPE    QUANTITY Bananas   2 Oranges   3 Kiwi          4   My goal is to Sum only Bananas and Oranges and have those sums show only...
  • Jihwan_Kim's avatar
    3 years ago

    Hi,

    Please check the below picture and the attached pbix file.

     

     

    expected measure one: = 
    CALCULATE (
        SUM ( Fruit[Quantity] ),
        KEEPFILTERS ( Fruit[Type] IN { "Bananas", "Oranges" } )
    )

     

    expected measure two: = 
    IF (
        HASONEVALUE ( Fruit[Type] ),
        SUM ( Fruit[Quantity] ),
        CALCULATE (
            SUM ( Fruit[Quantity] ),
            KEEPFILTERS ( Fruit[Type] IN { "Bananas", "Oranges" } )
        )
    )