Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DYNAMIC CURRENCY BY SLICER WITHOUT DAX

Hi All,

 

I have a table of values with numbers already converted from EUR to local currency. In this case i just need to add the currency symbol. The logic is: if i select Russia, i want to see "RUB" together my turnover - i have a table with countries and corresponding currency codes.

This formula was considered, but it's not working:

 

 

Currency Code = SWITCH(TRUE(),SELECTEDVALUE('Country'[Country]="Russia", FORMAT([MTD TGS LC], "RUB#")))
 
*MTD TGS LC: Sum of turnover on monthly level
 
What is the problem, please? Thanks!
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

    Assuming that you apply a slicer in your report that using Country field in the Country table, you can create the following measure to get the dynamic currency base on the selected country:

    Dynamic Currency =
    VAR _ctype =
        CALCULATE (
            MAX ( 'Country'[Type] ),
            FILTER ( 'Country', 'Country'[Country] = SELECTEDVALUE ( 'Country'[Country] ) )
        )
    RETURN
        CONCATENATE ( CONCATENATE ( _ctype, "#" ), [MTD TGS LC] )

    If the above one can't help you get the correct result, please provide some sample data, existing relationship between tables and your expected result with calculation logic and special examples(exclude sensitive info). Thank you.

    Best Regards

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous I'm very confused. If you want to select something in a slicer and have stuff happen dynamically there is a high probability that you will need DAX. And then you present DAX code. The code you have will produce something like RUB1000 for example. If you want the currency symbol for rubels then you would use UNICHAR(8381) So you could do something like: 

     

    Currency Code = SWITCH(TRUE(),SELECTEDVALUE('Country'[Country]="Russia",UNICHAR(8381)&[MTD TGS LC]))

     

    But, not sure that was what was not working or if there is something else?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Greg_Deckler 

       

      Thanks for your support, and you're right... it's already DAX, it was a misunderstanding from my side.

      I tried to apply your formula, and it doesn't work too.

       

       

       

       

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Anonymous Try adding a default return value of ,[MTD TGS LC] to the end of your SWITCH statement, to the immediate left of you last )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Assuming that you apply a slicer in your report that using Country field in the Country table, you can create the following measure to get the dynamic currency base on the selected country:

    Dynamic Currency =
    VAR _ctype =
        CALCULATE (
            MAX ( 'Country'[Type] ),
            FILTER ( 'Country', 'Country'[Country] = SELECTEDVALUE ( 'Country'[Country] ) )
        )
    RETURN
        CONCATENATE ( CONCATENATE ( _ctype, "#" ), [MTD TGS LC] )

    If the above one can't help you get the correct result, please provide some sample data, existing relationship between tables and your expected result with calculation logic and special examples(exclude sensitive info). Thank you.

    Best Regards

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous.

       

      Thanks a lot for your support! It's finally working. There's still one question from my side...

       

      I would like to have the opposite: currency code after numbers.

      In summary, instead of "RUB#1275239441.5" i would like "1275239441.5 RUB". How can i adapt my measure to achieve this goal?

      Thanks!

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        You can update the measure as below and check whether it is OK:

        Dynamic Currency =
        VAR _ctype =
            CALCULATE (
                MAX ( 'Country'[Type] ),
                FILTER ( 'Country', 'Country'[Country] = SELECTEDVALUE ( 'Country'[Country] ) )
            )
        RETURN
            CONCATENATE ( [MTD TGS LC]CONCATENATE ( " "_ctype ) )

        Best Regards