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
Gm0
Frequent Visitor

Evaluate IF based on two values in same column

Hello Community, 

I have a issue I can't wrap my head around... which I think is simple... but maybe not. 

  • I have a column with EP numbers 
  • A second with countries in which that EP is registred. 

I'm trying to get a IF statement to work to tell me if when an EP number is both registered in "X" and "Y"  (e.g. Greece & Cyprus)

the result should be a true / false. It is only true if the EP number is present in both country simultaneously. 

 

IF "For and EP number"  Has X and has Y as matching registration country (evaluated on all the values within that column for the same EP number)
= "True"

 

Thus for the table here below, the first two rows should return "True" as well as the two following one's. 

 

EPCountry
EP1469879Greece
EP1469879Cyprus
EP1523638Greece
EP1523638Cyprus
EP1565201Greece
EP1585548Greece
EP1585548Cyprus
EP1589941Greece
EP1617382Greece
EP1644558Greece
EP1654861Greece
EP1706471Greece
EP1735358Greece
EP1750538Greece
EP1750538Cyprus
EP1755483Greece
EP1830239Greece
EP1851372Greece
EP1855060Greece
EP1866492Greece
EP1871314Greece

 

Thank you very much for your help!

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @Gm0 ,

I created a calculated column to implement it. You could have a try.

Column = 
var d = CALCULATE(DISTINCTCOUNT('Table'[Country]),ALLEXCEPT('Table','Table'[EP]))
return 
IF(d>1, "True", BLANK())

1.PNG 

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

3 REPLIES 3
v-xuding-msft
Community Support
Community Support

Hi @Gm0 ,

I created a calculated column to implement it. You could have a try.

Column = 
var d = CALCULATE(DISTINCTCOUNT('Table'[Country]),ALLEXCEPT('Table','Table'[EP]))
return 
IF(d>1, "True", BLANK())

1.PNG 

Best Regards,

Xue Ding

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

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

Thanks all for your input! 

Anonymous
Not applicable

Hello,

 

Have you tried to make a measure where the functions IF and AND will be combined to one. 

You will have to use a formula like this: measure = IF(AND(country = "Greece"; country = "Cyprus") true; false)

 

 

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.