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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pbicorp
Frequent Visitor

Summary Table With Lag Calculation

I am working with a summary table and must create a lag from the Value (minutes) column. The calculated column cannot exceed 15 (as noticed from the Datetime column being 15 min increments). I have tried almost everything with creating indexes for the entire dataset and for each Person/ DateTime grouping with little to no luck calculating the lag. In this dataset, there is only one Person, but there are more so both Person and Datetime are essential for the lag calculation. Some values can overlap, as seen on 1/1/24 at 1:45, and must be added to the Lag output.

 

I'm excited to see how I should go about this as I have been able to get the value to lag one row after rather than filling the rest or getting a beautiful "not enough memory" message during the calculation.

 

DateTimePersonValueDesired Lag Output
1/1/24 1:00Joey5515
1/1/24 1:15Joey 15
1/1/24 1:30Joey 15
1/1/24 1:45Joey212
1/1/24 2:00Joey2515
1/1/24 2:15Joey 10
1/1/24 2:30Joey1615
1/1/24 2:45Joey45
3 REPLIES 3
rajendraongole1
Super User
Super User

Hi @pbicorp - you can create a calculated column as below to get the desired output.

 

LagOutput =
VAR CurrentDateTime = 'Table'[DateTime]
VAR CurrentValue = 'Table'[Value]
VAR PreviousRows =
FILTER(
'Table',
'Table'[Person] = EARLIER('Table'[Person]) &&
'Table'[DateTime] < CurrentDateTime
)
VAR CumulativeLag =
SUMX(PreviousRows,
MIN(15, IF('Table'[Value] = BLANK(), 15, 'Table'[Value]))
)
VAR LagWithCurrent = CumulativeLag + MIN(15, IF(CurrentValue = BLANK(), 15, CurrentValue))
RETURN
IF(CurrentValue = BLANK(), MIN(15, LagWithCurrent), MIN(15, CumulativeLag))

 

tested in power bi below is the output you can see in table chart.

 

 

rajendraongole1_0-1718944498674.png

 

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Sanity check. So, I entered the dataset as I presented it in my initial ask as a manually entered table. I then proceeded to make the calculated column with the logic you presented, but I am still not getting your results. 

 

I am completely confused on how this is.

Unfortunately, this is still not working for me. Could this be because I am working with a summarized table rather than a direct data source? Is there anything else I should look into or that I could provide to help solve this? I would like to state that there are/could be more blank values before and after datetimes that have a value. I tried to condense the dataset but that may have impacted how you carried out your calculation.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.