cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors