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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Bertenvanloover
Frequent Visitor

Find Text from List in Rows with same ID as current row

Hi, I could use some help finding a way to do the manipulation below in Power Query:
I want to create a custom column "Already_Approved" that shows
* "Yes" when chronologically² the last row in the same table with the same Document_ID has a transaction field that contains "Approving Done" or "Approved"
* and "No" when this chronologically last row does not have that Transaction.

Purpose: this table shows a history log of changes to the status of Documents, where each Document has a unique Document_ID. And I'd like to create a list of all non-approved Documents that are "Send for Approval" or "Send back for Editing". So after this step I will filter out only the "Send for Approval" and "Send back for editing" with "Already_Approved" = "No".

²Staying away from "chronologically" might create more robust results, though I don't want to overcomplicate my question 🙂 Cause for example "Document_ID=3" was send back after a mistake was found later on.

Document_IDTransactionDateAlready_Approved
1Created22/02/2023 11:00Yes
1Send for Approval22/02/2023 11:01Yes
1Approving Done22/02/2023 11:02Yes
2Created22/02/2023 11:05No
2Send for Approval22/02/2023 11:06No
3Created22/02/2023 11:00No
3Send for Approval22/02/2023 11:02No
3Send back for Editing22/02/2023 11:03No
3Send for Approval22/02/2023 11:05No
3Approved22/02/2023 11:10No
3Change Editing Required11/09/2023 09:11No

 

This is only my second Power Query to date, so I'm a complete rookie. Thanks for the help!

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

NewStep=let a=Table.Group(PreviousStepName,"Document_ID",{"n",each Table.Sort(_,{"Date",1}){0}[Transaction]}) in Table.AddColumn(PreviousStepName,"Already_Approved",each if a{[Document_ID=[Document_ID]]}[n]="Approved" then "Yes" else "No")

View solution in original post

2 REPLIES 2
Bertenvanloover
Frequent Visitor

Awesome Daniel! It made me swing my arms in the air for a winning gesture 😄
You made my day, I wish you an amazing weekend in return 😉

wdx223_Daniel
Community Champion
Community Champion

NewStep=let a=Table.Group(PreviousStepName,"Document_ID",{"n",each Table.Sort(_,{"Date",1}){0}[Transaction]}) in Table.AddColumn(PreviousStepName,"Already_Approved",each if a{[Document_ID=[Document_ID]]}[n]="Approved" then "Yes" else "No")

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.