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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
obothewizard
Helper I
Helper I

Create column based on multiple values

Hi there,

 

I am trying to create a calculated column based on a Zipcode table. I would like to add a field to indicate the US state based on the existing area field in the data table. For example I want to categorise New York where values in Area field are Bronx, Brooklyn, Queens etc.

Simply put it would be something like this in SQL :

 

State = IF Area IN ("Bronx", "Brooklyn", "Queens" ....) THEN "New York"
            ELSE IF Area IN ("Bergen County", "Essex County"...) THEN "New Jersey"

How can I replicate this logic for DAX? I have seen lots of articles on multiple conditions, but nothing so far describing how to categorise multiple values under one new column value. My use of SWITCH and IF logic is not allowing me to do this but maybe I'm implementing incorrectly.... 

Hope this makes sense, any help/pointers greatly appreciated 🙂

 

Screenshot of data table for reference!

 

obothewizard_0-1611918808453.png

 

Thanks!

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @obothewizard 

Create a calculated column:

State =
SWITCH (
    TRUE (),
    Table1[Area] IN { "Bronx", "Brooklyn", "Queens" }, "New York",
    Table1[Area] IN { "Bergen County", "Essex County" }, "New Jersey"
)

 where you'll have to complete  { "Bronx", "Brooklyn", "Queens" }  and { "Bergen County", "Essex County" } with all the values 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

4 REPLIES 4
AlB
Community Champion
Community Champion

Hi @obothewizard 

Create a calculated column:

State =
SWITCH (
    TRUE (),
    Table1[Area] IN { "Bronx", "Brooklyn", "Queens" }, "New York",
    Table1[Area] IN { "Bergen County", "Essex County" }, "New Jersey"
)

 where you'll have to complete  { "Bronx", "Brooklyn", "Queens" }  and { "Bergen County", "Essex County" } with all the values 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Hey thanks so much! I had written exactly the same logic when trying to write the DAX but I was using "(" instead of { !!

 

Thanks for the response 🙂

ibarrau
Super User
Super User

Hi, you can do it in a "New Column" in Power query (transform data) or DAX. Let's see DAX because you asked for it 🙂

NewColumn = 
IF ( 
    Table[Area] IN {"Bronx", "Brooklyn", "Queens" ....} 
    , "New York"
    , IF (
        Table[Area] IN {"Bergen County", "Essex County"...}
        , "New Jersey"
        , "Other"
    )
)

Hope that helps,

 


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

Happy to help!

LaDataWeb Blog

Hi there,

 

Thanks so much for your response. I actually used the calculated field with a switch statement as marked above, but thanks for this alternative approach - it can't hurt to have other ways of doing stuff!

Cheers 🙂

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.