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

Group by ID and subID and check if two values occur togheter

Hi,

I have a case where I wan't to find the combination of ID and Idref where Message and Search occurs together. I'm not sure how I can create the column "Contains Message & Search". It should group by ID and Idref and check if both Message and Search occurs. If it does, then for all rows for the combination of ID and Idref then return 1, otherwise just return 0.
I've tried some combinations of group by, summarize (but don't want to create a new table).. 
Would be great if someone can help me.

 

IDIdreftypeContains Message & Search
11Message0
11Given0
12Search0
12Given0
21Message1
21Search1
21Given1
31Message0
32Message0
32Given0
33Message1
33Search1
33Given1

 

Thanks!

1 ACCEPTED SOLUTION
Jonvoge
Super User
Super User

Hi.

 

You can use the following measure:

Jonvoge_0-1709289395369.png

 

Measure =

var HasMessage = CALCULATE(COUNTROWS('Table'), Filter(ALLEXCEPT('Table', 'Table'[Id], 'Table'[Idref]), 'Table'[type] = "Message"))
var HasSearch = CALCULATE(COUNTROWS('Table'), Filter(ALLEXCEPT('Table', 'Table'[Id], 'Table'[Idref]), 'Table'[type] = "Search"))

RETURN
If(HasMessage > 0 && HasSearch > 0, 1, 0)

_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Find me on LinkedIn, Sessionize, or my blog Downhill Data

View solution in original post

1 REPLY 1
Jonvoge
Super User
Super User

Hi.

 

You can use the following measure:

Jonvoge_0-1709289395369.png

 

Measure =

var HasMessage = CALCULATE(COUNTROWS('Table'), Filter(ALLEXCEPT('Table', 'Table'[Id], 'Table'[Idref]), 'Table'[type] = "Message"))
var HasSearch = CALCULATE(COUNTROWS('Table'), Filter(ALLEXCEPT('Table', 'Table'[Id], 'Table'[Idref]), 'Table'[type] = "Search"))

RETURN
If(HasMessage > 0 && HasSearch > 0, 1, 0)

_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Find me on LinkedIn, Sessionize, or my blog Downhill Data

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
Users online (2,296)