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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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]))

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.