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
Anonymous
Not applicable

Using IF IN Operator

Hi,

I tried the following dax which works using calculate, hwow to simply by using only If statement using IN operator

aps=CALCULATE(If(countrows(Pop)>0,"Yes","No"),Pop[city] IN {"Arizona","Arkansas","California","Colorado"})

I need something like below:

If(Pop[city] IN {"Arizona","Arkansas","California","Colorado"},"Yes","No")
I tried this way but column(Pop[city]) is not showing in DAX editor.

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Create a Measure.

 

Measure = IF ( MAX(Pop[city])) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

 

 

Incase you want to create a Calculated Column

Column = IF (Pop[city] IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Create a Measure.

 

Measure = IF ( MAX(Pop[city])) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

 

 

Incase you want to create a Calculated Column

Column = IF (Pop[city] IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

Thanks for the fast response.

 

Measure = IF ( MAX(Pop[city]) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

This measure works fine as long as in in table which i need to display on table.

 

I just test this one on "Card" visualization which gives "No". Out of 50 cities, i am checking only 4 cities.  The last city in the column is "Wyoming". 

When is used  to test : Measure2 = max(Pop[city]) Then "card" Visualization is display Last city "Wyoming".

 

My concern is as long as there is city value exist then display "Yes" either on the table or on the card.

 

Thanks.

 

Hi @Anonymous ,

 

Can you share sample data, your data model and your expected output to help you on this.

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

Hi Harshnathani,

 

Measure1 = IF ( MAX(Pop[city]) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

Measure2 = max(Pop[city])
 
Please find the 1Yes.PNG
 
No.CityPopulationMeasure1
24Alabama4859000No
48Alaska738400No
14Arizona6828000Yes
33Arkansas2978000Yes
1California39145000Yes
22Colorado5456500Yes
29Connecticut3590000No
45Delaware946000No
3Florida20271000No
8Georgia10215000No
40Hawaii1431000No
39Idaho1655000No
5Illinois12860000No
16Indiana6619000No
30Iowa3124000No
34Kansas2911000No
26Kentucky4425000No
25Louisiana4671000No
42Maine1329000No
19Maryland6006000No
15Massachusetts6794000No
10Michigan9922000No
21Minnesota5489000No
32Mississippi2992000No
18Missouri6084000No
44Montana1031000No
37Nebraska1896000No
35Nevada2891000No
41New Hampshire1330000No
11New Jersey8958000No
36New Mexico2085000No
4New York19796000No
9North Carolina10043000No
47North Dakota757000No
7Ohio11613000No
28Oklahoma3911000No
27Oregon4029000No
6Pennsylvania12802000No
43Rhode Island1056000No
23South Carolina4896000No
46South Dakota858500No
17Tennessee6600000No
2Texas27469000No
31Utah2996000No
49Vermont624600No
12Virginia8383000No
13Washington7170000No
38West Virginia1844000No
20Wisconsin5771000No
50Wyoming585500No
 

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.

Top Solution Authors