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
mwu1
New Member

Lookup value (with multiple results) from same table and with multiple filters

Hello, I have the following issue:

 

Context:

I currently have a report that tracks an activity log. 1 row = 1 activity. The row will tell us what is the activity (Activity ID (From)) and what is the next activity (Activity ID (To)) it triggers. Each row has a date-time (Activity Date) of when the Activity ID (From) happened. 

 

Objective:

For each row, I'd like to find out what is the Activity date for when Activity ID (from) = preceding Activity ID (to)

 

mwu1_1-1691376992441.png

 

 

I've tried the following formula

T0 = Calculate(firstNONBLANK(Reporting[ActivityDate], 1), Filter(Reporting, Reporting[ActivityToId] = EARLIER(Reporting[ActivityId])))
 
but it's only retrieving the first ever date of that activity instead of the closest preceding one. I would also like to add a filter so that it only looks up dates with the same Request ID (column A).
 
Thank you in advance!
2 REPLIES 2
mwu1
New Member

Managed to get an answer from further researching

 

T0 =
VAR _last_date = Reporting[ActivityDate]
RETURN
CALCULATE (
MAX ( Reporting[ActivityDate] ) ,
ALLEXCEPT ( Reporting , Reporting[ReqIDId] ) ,
Reporting[ActivityDate] < _last_date, Reporting[ActivityToId] = EARLIER(Reporting[ActivityId]))
Anonymous
Not applicable

Hi, @mwu1 

 

You have a great approach, thanks for sharing. You can accept your answer as a solution to help more people with similar problems.

 

Best Regards

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.