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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Calculate difference between consecutive rows - memory error

Hello,

 

I am trying to calculate the difference between chronological rows in my table but I'm getting a memory error whenever I try to execute the DAX command. The table (AAP - exits) is 45000 rows and the other table referenced (AAP) is 80000. AAP - exits is just a filtered version of AAP but if I change the references to all be to AAP - exits I get a circular reference error. My machine has 8 GB RAM.

 

Column 2 = CALCULATE(MAX(AAP[Timestamp]),AAP[IMO]=EARLIER('AAP - exits'[IMO]),AAP[Timestamp]<EARLIER('AAP - exits'[Timestamp]))
 
I've tried other variations of the formula, including DATESBETWEEN instead of the inequality because I read on here that can be more efficient. But EARLIER doesn't work within DATESBETWEEN and I cannot find another way to refer to the current row. 
 
Would be open to solutions in DAX or Power Query. 
 
Thanks for your time.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to try this code to create a calcualted column,

Column 2 =
CALCULATE (
    MAX ( AAP[Timestamp] ),
    FILTER (
        AAP,
        AAP[IMO] = EARLIER ( 'AAP - exits'[IMO] )
            && AAP[Timestamp] < EARLIER ( 'AAP - exits'[Timestamp] )
    )
)

If you code will still return memory error, please refer to this offical blog to optmize your data model.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to try this code to create a calcualted column,

Column 2 =
CALCULATE (
    MAX ( AAP[Timestamp] ),
    FILTER (
        AAP,
        AAP[IMO] = EARLIER ( 'AAP - exits'[IMO] )
            && AAP[Timestamp] < EARLIER ( 'AAP - exits'[Timestamp] )
    )
)

If you code will still return memory error, please refer to this offical blog to optmize your data model.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you, this worked!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.