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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
snifer
Post Patron
Post Patron

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

1 ACCEPTED SOLUTION

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"
)

View solution in original post

7 REPLIES 7
d_gosbell
Super User
Super User

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

@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

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"
)

@d_gosbell 

 

yes that is my goal

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

 

using your formula I got this error:

 

A single value for column 'value' in table 'CurrencySelector2' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Capture4.PNGas you see there is just 1 column 1 row

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"
)

@d_gosbell 

Now the check working, but if it is not selected local currency is displaying always "ERROR Multiple Currencies"

 

I need to add the case if the local currency is not selected

 

SELECTEDVALUE(CurrencySelector2[value]) not "Local Currency"

 

to do not do the check and just display "ok"


I need to add the case if the local currency is not selected 

 to do not do the check and just display "ok"


Oh, OK, this was not clear to me from your earlier post. Moving the check for "Local Currency" to an outer IF like the following should do what you want.

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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