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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ckwongak
Frequent Visitor

How to return table based on condition with DAX?

Hi all,

 

I have two slicer, one slicer contains the full name of country (for e.g. Japan), one table contains the mapping of the currency for that country and one table contains only one row "USD" as the currency

 

I want to have one slicer with options below:

 

If one country is selected, I will show two currency (e.g. if japan is selected, I will show JPY, USD)

If more than one country is selected, I will always show USD 

 

How to do this in Power BI?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ckwongak ,

 

My Sample is as below.

Currency:

vrzhoumsft_0-1682578049940.png

DimCountry:

vrzhoumsft_1-1682578060471.png

Table:

vrzhoumsft_2-1682578066749.png

Data model:

vrzhoumsft_3-1682578109438.png

Measure:

Currency Appear when only one country is selected = 
VAR _SELECTVALUE =
    SELECTEDVALUE ( 'Currency'[Currency] )
VAR _COUNT =
    COUNTAX ( VALUES ( DimCountry[Country] ), [Country] )
RETURN
    IF ( _COUNT = 1, CALCULATE ( SUM ( 'Table'[USD] ) ) * _SELECTVALUE )

Result is as below.

vrzhoumsft_4-1682578146669.png

vrzhoumsft_5-1682578154555.png

 

Best Regards,
Rico Zhou

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @ckwongak ,

 

My Sample is as below.

Currency:

vrzhoumsft_0-1682578049940.png

DimCountry:

vrzhoumsft_1-1682578060471.png

Table:

vrzhoumsft_2-1682578066749.png

Data model:

vrzhoumsft_3-1682578109438.png

Measure:

Currency Appear when only one country is selected = 
VAR _SELECTVALUE =
    SELECTEDVALUE ( 'Currency'[Currency] )
VAR _COUNT =
    COUNTAX ( VALUES ( DimCountry[Country] ), [Country] )
RETURN
    IF ( _COUNT = 1, CALCULATE ( SUM ( 'Table'[USD] ) ) * _SELECTVALUE )

Result is as below.

vrzhoumsft_4-1682578146669.png

vrzhoumsft_5-1682578154555.png

 

Best Regards,
Rico Zhou

 

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

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.