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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Lookup Multiple Rows and Return Yes or No

Hi all,

 

I have a table which looks like this:

container_nrStatus
OOLU3874481completed
OOLU3874481pending
OOLU3874481rejected
OOLU3333333pending

 

I am looking for a formula for the following. If there are multiple rows with the same 'container_nr', and the 'Status' of one of these rows is 'completed', I want a 'yes' in an extra column:

 

Hope someone can help me with this?!

regards,

John

 

container_nrStatuscompleted?
OOLU3874481completedyes
OOLU3874481pendingyes
OOLU3874481rejectedyes
OOLU3333333pendingno
3 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=IF(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[container_nr]=EARLIER(Data[container_nr])&&Data[Status]="Completed"))>=1,"Yes","No")

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Are there multiple tables involved here? The example I put together was for everything in a single table and it seemed like it was returning the correct status.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

good day  Greg,

 

here is what i did: I took a beer, had a good rest, tried it again and found out it is woking fine.

Thank you so much!

 

john

 

 

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=IF(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[container_nr]=EARLIER(Data[container_nr])&&Data[Status]="Completed"))>=1,"Yes","No")

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

good day  Ashish,

 

here is what i did: I took a beer, had a good rest, tried it again and found out it is woking fine.

Thank you so much!

 

john

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

You want EARLIER:

 

completed = 
VAR __table = FILTER(ALL('Table14'),[container_nr] = EARLIER([container_nr]) && [Status] = "completed")
RETURN
IF(COUNTX(__table,[Status])>=1,"yes","no")

See table 14 of attached. 

 

Also, here is a good article on EARLIER:

 

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

I am almost there, but one thing is not correct.

your formula gives me also a 'yes' for the OOLU3890311.

This is not correct, as this container_nr has the status PENDING.

Can you please advise?

 

completed? =
VAR __table =
    FILTER (
        ALL ( OOCL_RTM_Depotsmart_PTI );
        OOCL_RTM_Depotsmart_PTI[Container_nr] = EARLIER ( [container_nr] )
            && [Status] = "completed"
    )
RETURN
    IF ( COUNTX ( OOCL_RTM_Depotsmart_PTI; [Status] ) >= 1; "yes"; "no" )

 

container_nrContainer_nrStatuscompleted?
OOLU3874481OOLU3874481completedyes
OOLU3874481OOLU3874481pendingyes
OOLU3874481OOLU3874481rejectedyes
OOLU3890311OOLU3890311pendingyes

Are there multiple tables involved here? The example I put together was for everything in a single table and it seemed like it was returning the correct status.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

good day  Greg,

 

here is what i did: I took a beer, had a good rest, tried it again and found out it is woking fine.

Thank you so much!

 

john

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.