user12217470
user12217470

Reputation:

What is the correct way to use an IF CONTAINS statement in DAX?

I am trying to to create a new column in my data model that shows a 1 if a zip code exists within another column else the column will return a 0 for a given value if not within the list. I feel like it might have to do with the format that the "Zip Code" column might be in, but even changing the formatting of the code still produces an error. "Encounters" is the name of the table where the "Zip Code" column exists.

fake_county = if Table.Contains({64728, 84728, 32487},[Zip Code]) then "1" else "0"

Upvotes: 0

Views: 488

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

For DAX, this would be the syntax for a calculated column on the Encounters table:

IF ( Encounters[Zip Code] IN { 64728, 84728, 32487 }, "1", "0" )

Your code looks more like the Power Query M language though.

Upvotes: 1

Related Questions