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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
EVG-Questions
Frequent Visitor

How to filter ID values containing specific values

This is a follow-up to a different question I had, which was solved by @PaulDBrown.

I'm trying to find all ID values containing specific values. Example given here:

PowerBI Vraag 1.png

In this example I need to find all ID values that contain either "A" or "D" then assign a "1" to all rows with one of those ID values, regardless if the row contains "A", "D" or both. 

1 ACCEPTED SOLUTION

Apologies...I was overthinking this. Try:

 

 

Only A or D =
VAR _Table =
    CALCULATETABLE (
        VALUES ( 'FactTable'[Cat1] ),
        ALLEXCEPT ( FactTable, FactTable[ID] )
    )
VAR _Vals = { "A", "D" }
VAR _Excpt =
    EXCEPT ( _Table, _Vals )
RETURN
    IF ( COUNTROWS ( _Excpt ) >= 1, 0, 1 )

 

 

Only A and or D.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@EVG-Questions ,  create a measure like

measure =

var _cnt = calculate(distinctcount(Table[cat1]) , filter(allselected(Table), Table[ID] =max(Table[ID])))
var _cnt2 = calculate(distinctcount(Table[cat1]) , filter(allselected(Table), Table[ID] =max(Table[ID]) && Table[cat1] in {"A", "D"}))
return
if(_cnt=2 && _cnt=_cnt2 ,1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This doesn't seem to be working for me. The measure only generates "0". Could you perhaps explain the thought behind your approach?

Try:

Countrows A or D =
VAR _Table =
    CALCULATETABLE (
        VALUES ( 'FactTable'[Cat1] ),
        ALLEXCEPT ( FactTable, FactTable[ID] )
    )
VAR _Vals = { "A", "D" }
VAR _INTS =
    INTERSECT ( _Table, _Vals )
RETURN
    IF ( COUNTROWS ( _INTS ) >= 1, 1, 0 )

A or D.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks for the response @PaulDBrown!

This appears to be one step closer but doesn't quite solve it.

I'd like to get a list that exclusively consists of "A", "D" or both, whereas this creates a list of ID's that can also contain other values as long as there is an "A", "D" or both present.

Got it. I'm not in front of a PC now but try:

Countrows A or D =
VAR _Table =
CALCULATETABLE (
VALUES ( 'FactTable'[Cat1] ),
ALLEXCEPT ( FactTable, FactTable[ID] )
)
VAR _Vals = { "A", "D" }
VAR _INTS =
INTERSECT ( _Table, _Vals )
VAR _NotADCat =
EXCEPT ( _Table, _Vals )
VAR _Clean =
EXCEPT ( _INTS, _NotADCat )
RETURN
IF ( COUNTROWS ( _Clean ) >= 1, 1, 0 )





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I might be doing something wrong, but it seems that this code produces the same outcome as your previous measure.

Apologies...I was overthinking this. Try:

 

 

Only A or D =
VAR _Table =
    CALCULATETABLE (
        VALUES ( 'FactTable'[Cat1] ),
        ALLEXCEPT ( FactTable, FactTable[ID] )
    )
VAR _Vals = { "A", "D" }
VAR _Excpt =
    EXCEPT ( _Table, _Vals )
RETURN
    IF ( COUNTROWS ( _Excpt ) >= 1, 0, 1 )

 

 

Only A and or D.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks so much!

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.