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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JoeCrozier
Helper II
Helper II

Create True/False variable based on other row grouping

This might be pretty similar to this one: https://community.fabric.microsoft.com/t5/Desktop/Determine-if-a-value-exists-in-one-column-when-gro...

 

but I have data like this in Power Query:

ProtocolIRB Committee
AdvilCIRB
AdvilCIRB
CancerDrugLIRB
LS-P-JoeCIRB
LS-P-JoeLIRB
SkiCIRB
SkiLIRB
TestCIRB
YoutubeLIRB
YoutubeLIRB
YoutubeLIRB

 

I need to create a new variable that is 'TRUE' if both LIRB and CIRB exist for a given protocol, but false if only one of them exists for the protocol.

 

So for example, Ski has two rows, one for LIRB and one for CIRB, so ski is true.  

Youtube has only LIRB, so its false.

And CancerDrug only has one row, so its only got one of the two, so its false.

 

My ideal output would look like this:

ProtocolIRB CommitteeBoth
AdvilCIRBFALSE
AdvilCIRBFALSE
CancerDrugLIRBFALSE
LS-P-JoeCIRBTRUE
LS-P-JoeLIRBTRUE
SkiCIRBTRUE
SkiLIRBTRUE
TestCIRBFALSE
YoutubeLIRBFALSE
YoutubeLIRBFALSE
YoutubeLIRBFALSE

 

 

I also have other columns not shown (action_date, submit_date, etc..), and need to do more transformations down the road, so hopefully however I accomplish this doesnt drop any columns I'll need.  Any help would be appreciated!

1 ACCEPTED SOLUTION

@JoeCrozier 

 i am not good at M, here is a workaround for you





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
ryan_mayu
Super User
Super User

@JoeCrozier 

 if there are only 2 values in IRB you can try this

Column = if( CALCULATE(DISTINCTCOUNT('Table'[IRB Committee]),ALLEXCEPT('Table','Table'[Protocol]))=2,TRUE(),FALSE())
 
if you will have other  data in IRB, you need to try this
 
Column 2 = if('Table'[IRB Committee]="CIRB"&&maxx(FILTER('Table','Table'[Protocol]=EARLIER('Table'[Protocol])&&'Table'[IRB Committee]="LIRB"),'Table'[IRB Committee])<>"" || 'Table'[IRB Committee]="LIRB"&&maxx(FILTER('Table','Table'[Protocol]=EARLIER('Table'[Protocol])&&'Table'[IRB Committee]="CIRB"),'Table'[IRB Committee])<>"",TRUE(),FALSE())
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu  Thank you, I believe that will probably work.  There are only two options in that column (well, there are also blanks, will that be a problem you think?).  However I'm having trouble implementing it.  In this picture you'll see the actual column names (slightly diffent than what I gave you).   And I'm assuming in your code where it said 'table' that should be the name of the table?  If so its LIRB Approval and you can see that there.

The problem is it says its expecting a token ')' and I cant see where that would fit:

JoeCrozier_0-1712752225556.png

 

Any ideas?  Am I missing something obvious?

not creating a column in PQ. you need to close the PQ window and use DAX to create a column

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Will it still then be available later on in Power query?  I need to do later power query steps based on that column being available.

@JoeCrozier 

 i am not good at M, here is a workaround for you





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This seems to work great!  To make sure i understand it and can implement, seems like you: copied the query, in the new copy you grouped by protocol and counted, and then you merged that count back into the original query, and created a true/false column for if the count was 2?

yes, any other issues you encountered?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nope, worked great!

ok, glad to hear that





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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