Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

check if same currency

  
company namecurrency
unoeur
dueeur
treusd

 

let's say my table like this

i make filtering based on company column:

if i select company "uno"it will say that currency dispayed is "eur"

but now if a make multiple selections, I want to create a measure that will check if all selection have the same currency

so If i select "uno' and "tre" will say error difference currency

  • Sorry, I cut and pasted your examples and did not notice the syntax error in your selectedvalue call. The closing bracket is in the wrong position, it should look like the following:

     

    CCheck = IF(
    COUNTROWS(VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode]))=1
    && SELECTEDVALUE(CurrencySelector2[value])="Local Currency", VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode])
    , "ERROR Multiple Currencies"
    )

7 Replies

  • You could do this in a measure with an expression like the following:

     

    = IF( COUNTROWS(VALUES(Table1[currency]))=1, VALUES(Table1[currency]), "ERROR Mulitple Currencies")
     
    replacing "table1" for the real name of your table
    • Anonymous's avatar
      Anonymous
      Not applicable

      d_gosbell 

       

      I adapted your script and it is work,

      but now I need to add a condition, I try to add but it doesn't work, maybe you can give a look

      i need to ahh that need to make this check just in case that "Local Currency" is Selected

      i was thinking of

      IF(SELECTEDVALUE(CurrencySelector[value]="Local Currency"),)

      so fill script looks like:

       

      CCheck = IF(SELECTEDVALUE(CurrencySelector[value]="Local Currency"),) && IF( COUNTROWS(VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode]))=1, VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode]), "ERROR Mulitple Currencies")))
       
      but give me a syntax error don't know why
      • d_gosbell's avatar
        d_gosbell
        Super User
        but give me a syntax error don't know why

        Well that would probably be because this

         

        IF(SELECTEDVALUE(CurrencySelector[value]="Local Currency"),)

         

        is not valid. IF expects at least 2 arguments and you are only supplying 1.

         

        I'm not sure I really understand your requirement. But if you want to check that both CurrencySelector[value] = "Local Currency" and that there is only 1 GroupStructure.CurrencyCode then something like the following might work:

         

        CCheck = IF(
        COUNTROWS(VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode]))=1
        && SELECTEDVALUE(CurrencySelector[value]="Local Currency")
          , VALUES(UploadAccountsCurrentyPeriod[GroupStructure.CurrencyCode])
          , "ERROR Multiple Currencies"
        )