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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
newbie_but_conf
Helper II
Helper II

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
Solution Supplier
Solution Supplier

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
Solution Supplier
Solution Supplier

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.