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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
ellevy12
Frequent Visitor

Calculating difference between consecutive rows

hello

 

i am new to power bi , and i have some struggle with this. 

 

my data look like this (small portion:)

DATE / sum

2018-07-01 / 200

2017-09-03 / 400

2016-19-04 / 500

 

i want to calculate the difference between those dates , so i want to create new column:

 

DATE / sum / new column

2018-07-01 / 200    /    400

2017-09-03 / 400   /    500

2016-19-04 / 500 /   

 

only problems on the data sets: 

1. dates are not strictly consecutive , meaning i can have 5 dates in 2018 and 10 dates in 2017 

2. i want those calculation to be filtred by the user. meaning - if user deselect the '2017-09-03' date , then calculation will changed to the following:

 

DATE / sum / new column

2018-07-01 / 200    /    500

2016-19-04 / 500 /   

 

 

thanks.

1 ACCEPTED SOLUTION

Hi all,

 

i manged to solve this using this answer:

 

Answer

 

basicly i had to calculate for each date the previous date (under the current filters) and then return the result for that date

 

View solution in original post

7 REPLIES 7
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @ellevy12,

 

Please provide a sample of the original data. Since the dates aren't in order by dates, how can we determine which one is former, which one is latter?

 

 

Best Regards,
Dale

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

Hi all,

 

i manged to solve this using this answer:

 

Answer

 

basicly i had to calculate for each date the previous date (under the current filters) and then return the result for that date

 

Thanks for sharing, @ellevy12.

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Up until that last requirement, you could have just used a calculated column with EARLIER.

 

Now, you will need a measure and use a VAR to grab your current table (as filtered by user). Then, use ADDCOLUMNS to add a column using EARLIER to that table and do your calculations.

 

Here is an article on the use of EARLIER:

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

sorry i think i mix things up.. actualy what i reffered to as my data is actualy a visual matrix / table  based on the data.

 

does this change somthing ?

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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...
LivioLanzo
Solution Sage
Solution Sage

You cannot do this by using a Calculated Column but you can do it using a Measure. Is a measure ok?   Also can you include in the dataset you have provided any column that is relevant for the calculation

 

 

 


 


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


Proud to be a Datanaut!  

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.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.