Forum Discussion

ckwongak's avatar
ckwongak
Frequent Visitor
3 years ago
Solved

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"...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi ckwongak ,

     

    My Sample is as below.

    Currency:

    DimCountry:

    Table:

    Data model:

    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.

     

    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.