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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
RDA_PowerBI
Frequent Visitor

Calculate Difference Between Previous Row

Hi,

 

I am looking for help calculating the difference between the Numbers column below if  'Table'[Book] = EARLIER ('Table'[Book]) . The column below is what I would need. This would help determine if Numbers were skipped if Column => 1

 

BookNumbersColumn
A10
A21
A53
A83
A91
A123
A153
A161
A171
A258

 

Any help is appreciated.  

 

 

1 ACCEPTED SOLUTION

Right, so you would subtract the numbers. The intention was to show you how to use MAXX/MINX coupled with EARLIER and other filters to figure out the previous row value that you want to target and then you can use that to calculate what you want.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=if(ISBLANK(CALCULATE(MAX(Table1[Numbers]),FILTER(Table1,Table1[Book]=EARLIER(Table1[Book])&&Table1[Numbers]<EARLIER(Table1[Numbers])))),BLANK(),[Numbers]-CALCULATE(MAX(Table1[Numbers]),FILTER(Table1,Table1[Book]=EARLIER(Table1[Book])&&Table1[Numbers]<EARLIER(Table1[Numbers]))))

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hey thank you for your reply. Is it possible to have a calculated measure for this scenario. As the data i have to deal with contains so many rows and with calculated columns it takes alot of time. And our basic necessity is to reduce the time for the reporting. 

 

Thank you 

Anonymous
Not applicable

This is awesome and if you were doing this with dates just substitue with Datediff vs the -. 
Thanks again!

Greg_Deckler
Community Champion
Community Champion

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I can't use DATEDIFF because there is no date in this case. 

Right, so you would subtract the numbers. The intention was to show you how to use MAXX/MINX coupled with EARLIER and other filters to figure out the previous row value that you want to target and then you can use that to calculate what you want.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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