Forum Discussion

ViralPatel212's avatar
ViralPatel212
Resolver I
2 years ago
Solved

Sum value based on Selected filters

Hi Team,   I am trying to show different values based on the currency selection.   Here are the Rules Sum Vol : 1) IF 1 currency is selected than show sum of 1 currency 2) IF 1 or more currenc...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ViralPatel212 

     

    For your question, here is the method I provided:

     

    Here's some dummy data

     

    "Dealer Ranking"

     

    Create a measure. Count the total number of selected slicers.

     

    Currency Count = 
        COUNTROWS(
            VALUES('Dealer Ranking'[Currency])
        )

    Create a measure. Calculate the sum of Ranking Size.

     

    Ranking Size (Vol) = 
    VAR CurrencyCount = [Currency Count]
    VAR SelectedCurrency = IF(HASONEVALUE('Dealer Ranking'[Currency]), SELECTEDVALUE('Dealer Ranking'[Currency]), BLANK())
    VAR SumSingleCurrency =
        CALCULATE(
            SUM('Dealer Ranking'[Ranking Size]),
            'Dealer Ranking'[Currency] = SelectedCurrency
        )
    VAR SumEURConverted =
        SUMX(
            'Dealer Ranking', 
            [Ranking Size]
        )
    VAR SumAllCurrencies =
        CALCULATE(
            SUM('Dealer Ranking'[Ranking Size]),
            ALL('Dealer Ranking'[Currency])
        )
    RETURN
        SWITCH(
            TRUE(),
            CurrencyCount = 1, SumSingleCurrency,
            CurrencyCount = 2, SumEURConverted,
            SumAllCurrencies)

     

    Here is the result.

     

     

     

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.