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

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

Reply
nikitak224
New Member

Need help! How to create a filter based on groups with the same values

I am trying to create a filter of groups based on values of an existing field (States). 

 

These are the values in the Field, State: NJ, CT, TX, AR, CA, None

 

Group 1: All States (NJ, CT, TX, AR, CA)

Group 2: None

Group 3: CT, TX, AR, CA (Excluding NJ)

Group 4: NJ

 

I tried to create groups function, but since NJ is used in multiple groups, that wasn't working.

Any help would be appreciated. Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @nikitak224 ,

I created some data:

vyangliumsft_0-1674012485494.png

Here are the steps you can follow:

1. Enter data – Create a table.

vyangliumsft_1-1674012485495.png

2. Create measure.

Flag =
var _select=SELECTCOLUMNS('Table',"1",[State])
VAR _SELECT1=SELECTEDVALUE('Table2'[Group])
return
SWITCH(
    TRUE(),  
    AND(_SELECT1="Group1" , "NJ" in _select || "CT" in _select || "TX" in _select || "AR" in _select ||"CA"  IN _select ),1,
    _SELECT1="Group2" ,1,
    AND(_SELECT1= "Group3" , NOT("NJ")  IN _select),1,
   AND(_SELECT1="Group4" , "NJ" IN _select),1,0
)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1674012485496.png

4. Result:

Select the corresponding Slicer to display the corresponding rules

vyangliumsft_3-1674012485497.png

 

Best Regards,

Liu Yang

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @nikitak224 ,

I created some data:

vyangliumsft_0-1674012485494.png

Here are the steps you can follow:

1. Enter data – Create a table.

vyangliumsft_1-1674012485495.png

2. Create measure.

Flag =
var _select=SELECTCOLUMNS('Table',"1",[State])
VAR _SELECT1=SELECTEDVALUE('Table2'[Group])
return
SWITCH(
    TRUE(),  
    AND(_SELECT1="Group1" , "NJ" in _select || "CT" in _select || "TX" in _select || "AR" in _select ||"CA"  IN _select ),1,
    _SELECT1="Group2" ,1,
    AND(_SELECT1= "Group3" , NOT("NJ")  IN _select),1,
   AND(_SELECT1="Group4" , "NJ" IN _select),1,0
)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1674012485496.png

4. Result:

Select the corresponding Slicer to display the corresponding rules

vyangliumsft_3-1674012485497.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.