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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.