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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

For Each/Exists type of calculation in DAX

Hi,

 

Input table

Feature IDTitle FlagWorkshop Status Output
RFID0013011
RFID0013011
RFID0013011
RFID0012011
RFID0012021
RFID0012031
RFID0022040
RFID0022050
RFID0022060
RFID0032020
RFID0032040
RFID0032050

 

Above is my example table. Here I want to see if for each Feature ID if there exists Title Flag 202 and 203 both, then I want my Workshop Status = 1. If there exists only 1 out of the 2 titles 202 and 203, my Workshop STatus would still be 0(See RFID003)

 

How can i implement this in Power BI.

I prefer this solution in M Code, but I know it gets messy there. In that case DAX is also fine.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please follow these steps:

1.Duplicate table-->Group and Combine values:

2.15.1.1.PNG

2. Add a custom column:

2.15.1.2.PNG

3. Merge these two tables:
2.15.1.3.gif

 

Or use the following formula in DAX to create a new column:

Column =
VAR _all =
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Feature ID] = EARLIER ( 'Table'[Feature ID] ) ),
        [Title Flag]
    )
RETURN
    IF ( 202 IN _all && 203 IN _all, 1, 0 )

 

The final output is shown below:

2.15.1.4.PNG

 

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Please follow these steps:

1.Duplicate table-->Group and Combine values:

2.15.1.1.PNG

2. Add a custom column:

2.15.1.2.PNG

3. Merge these two tables:
2.15.1.3.gif

 

Or use the following formula in DAX to create a new column:

Column =
VAR _all =
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Feature ID] = EARLIER ( 'Table'[Feature ID] ) ),
        [Title Flag]
    )
RETURN
    IF ( 202 IN _all && 203 IN _all, 1, 0 )

 

The final output is shown below:

2.15.1.4.PNG

 

Please take a look at the pbix file here.

 

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

lbendlin
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnLzdDEwMFTSUTIGk4ZKsTrkihrhEDXCKmqMJmoEFjUBkgYYoqZYRc3QRI3htmGKoptrjGxuLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Feature ID" = _t, #"Title Flag" = _t, #"Workshop Status Output" = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Feature ID"}, {{"titles", each _, type table [Feature ID=nullable text, Title Flag=nullable text, Workshop Status Output=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Status", each if Table.Contains([titles],[#"Title Flag"="202"]) and Table.Contains([titles],[#"Title Flag"="203"]) then 1 else 0),
    #"Expanded titles" = Table.ExpandTableColumn(#"Added Custom", "titles", {"Title Flag"}, {"Title Flag"})
in
    #"Expanded titles"

Helpful resources

Announcements
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!

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.

Top Solution Authors