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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KayCon
Frequent Visitor

Switch() using multiple conditions within same ID

Afternoon All,

 

I am trying to calulate a column to group these ID groups into the correct zones. I've made a dummy table to try and explain what I mean. All have to be within the same ID.

Zone A - Has child under 4 within same ID group

Zone B - Has child between 16-18 within same ID group 

Zone C - Anything else

 

I know how to do a simple switch(,True() command however I cannot figure out how to check if any of the ID group contains these conditions. Please if anyone could help it would help me so much.

idNameLead NameAgeIs AdultIs Child
123Name1Name13110
123Name2Name12710
123Name3Name17510
322Name4Name4401
322Name5Name42510
2 REPLIES 2
FreemanZ
Super User
Super User

hi @KayCon 

try to add a calculated column like:

Zone = 
SWITCH(
    TRUE(),
    COUNTROWS(
        FILTER(
            data,
            data[id]=EARLIER(data[id])
                &&data[age]<=4
                &&data[Is Child]=1            
        )
    )<>0,    
    "Zone A",
    COUNTROWS(
        FILTER(
            data,
            data[id]=EARLIER(data[id])
                &&data[age]<=18
                &&data[age]>=16
                &&data[Is Child]=1            
        )
    )<>0,    
    "Zone B",
    "Zone C"
)

it worked like:

FreemanZ_0-1698071976677.png

That worked perfectly, thank you for your help 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.