Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ViralPatel212
Resolver I
Resolver I

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 currency is selected than show sum of EURconverted

3) IF nothing is selected than show All Currency 

The dax below works for rule 1 and 3 but not 2.

I have tried using a count curreny dax : 

Currency Count( ranking) = COUNTROWS(SUMMARIZE('Dealer Ranking','Dealer Ranking'[Currency]))
but this doesn't seem to work.
 

Here is my dax

 

Ranking Size (Vol) =
VAR Allcurrency =
    CALCULATE(
        [Ranking Size],
        FILTER(
        'Dealer Ranking',
        'Dealer Ranking'[Type] = "Vol. (MM)" &&
'Dealer Ranking'[All] =0
        )
)
VAR ALLEUR =
    CALCULATE(
        [Ranking Size],
        FILTER(
        'Dealer Ranking',
        'Dealer Ranking'[Type] = "Vol. (MM)" &&
'Dealer Ranking'[All] = 1
        )
)
VAR ALLUSD =
    CALCULATE(
        [Ranking Size],
        FILTER(
        'Dealer Ranking',
        'Dealer Ranking'[Type] = "Vol. (MM)" &&
'Dealer Ranking'[All] = 2
        )
)
VAR ALLGBP =
    CALCULATE(
        [Ranking Size],
        FILTER(
        'Dealer Ranking',
        'Dealer Ranking'[Type] = "Vol. (MM)" &&
'Dealer Ranking'[All] = 3
        )
)

RETURN

SWITCH(
    TRUE(),
    SELECTEDVALUE('Dealer Ranking'[Currency]) = "ALL (EUR)", ALLEUR,
    SELECTEDVALUE('Dealer Ranking'[Currency]) = "ALL (USD)", ALLUSD,
    SELECTEDVALUE('Dealer Ranking'[Currency]) = "ALL (GBP)", ALLGBP,
    Allcurrency
  )

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ViralPatel212 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"Dealer Ranking"

vnuocmsft_0-1707122498340.png

 

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

 

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

vnuocmsft_2-1707122611417.png

vnuocmsft_3-1707122634403.png

vnuocmsft_4-1707122700408.png

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.

vnuocmsft_6-1707122837259.png

 

vnuocmsft_7-1707122851596.png

 

vnuocmsft_5-1707122822710.png

 

vnuocmsft_8-1707122886532.png

 

Regards,

Nono Chen

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

 

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @ViralPatel212 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"Dealer Ranking"

vnuocmsft_0-1707122498340.png

 

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

 

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

vnuocmsft_2-1707122611417.png

vnuocmsft_3-1707122634403.png

vnuocmsft_4-1707122700408.png

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.

vnuocmsft_6-1707122837259.png

 

vnuocmsft_7-1707122851596.png

 

vnuocmsft_5-1707122822710.png

 

vnuocmsft_8-1707122886532.png

 

Regards,

Nono Chen

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

 

 

 

 

bolfri
Solution Sage
Solution Sage

Can you share some sample data to work with? 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.