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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.