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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.