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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Ray_Brosius
Helper III
Helper III

how do you check the value of a column from previous rows

I have a challenge that I think is easy.. but I can't remember how to do it.. 

Below is a screenshot of sample data..  This is a table of "snapshot" data  for each object we capture Monthly snapshots into one table of some attributes.. like close date and amount.

I want to check if the Close date has changed and if the Amount has changed. ( I'll want to know by how much but for now just looking to get the M CODE logic to be able to check the previous snapshot for each object for changes to Close Date and Amount.. 

 

Ray_Brosius_1-1629832888990.png

 

 

1 ACCEPTED SOLUTION

Hi  @Ray_Brosius ,

 

Below is a blog telling how to achieve it in 2 ways:

https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/power-bi-data-sources/p...

I made a sample .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

You don't even need to make a copy of the table.  You can choose the same table as your right table in the merge dialogue, and merge the table to itself.

 

--Nate

Anonymous
Not applicable

The least painful way is to add two index columns, one starting at 1 and o e starting at 0. Then use the Merge function in the GUI. Choose the index starting at 1 from your first table, and the one starting at 0 from the right table. Now your values will line up left to right, and you can do each [Columnx] = [Columny] comparisons.

 

--Nate

@Anonymous    I seem to remember this..   I will play with it.. but a clarification question..

1) I need to make a copy of the table and then have one index on both tables, one starting at 0 and one starting at 1.  Then Merge the two tables correct? 

 

 

Hi  @Ray_Brosius ,

 

Below is a blog telling how to achieve it in 2 ways:

https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/power-bi-data-sources/p...

I made a sample .pbix file,pls see attached.

 

Best Regards,
Kelly

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

Greg_Deckler
Community Champion
Community Champion

@Ray_Brosius 

Whoops, missed that this was Power Query, let me try to remember that one. Below is DAX. Can you paste that example data as text?

 

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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