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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jhollingworth
Frequent Visitor

Quick comparison of values on same table

Hello,

I have a table with two columns, "Date" and "NDC". I am trying to figure out a way to determine when an NDC is added or removed based on the previous date. The list is updated randomly, so the previous date could be a day, week, or month prior to. Below is what I am going for, but if another way exists that is better, I am open to it.

 

DateNDCStatus
6/14/202400074-6215-13Removed
6/14/202400074-7126-13Removed
6/14/202400169-1833-11No Change
6/14/202400169-1834-11No Change
7/29/202400169-1833-11No Change
7/29/202400169-1834-11No Change
7/29/202400597-0375-97New
7/29/202400597-0400-89New

 

In this example, the first two NDCs have been removed as they are on 6/14/24, but not on the next date's file 7/29/24. The next two NDCs are on both files, so No Change is the result. Finally, the last two NDCs are on 7/29/2024 but are not on 6/14/24, thus the New status.

 

I have used the below to figure out the New NDCs, but I am having trouble getting the removed.

 

New NDC Matrix =
VAR PREVD = OFFSET( -1, ORDERBY('Table'[Date] ) )
RETURN
IF (COUNTX(FILTER('Table',[NDC] = EARLIER([NDC]) && [Date]=PREVD), [NDC])=0, "New", "No Change")


Any help is appreciated.
Thank you!
1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

You might find my recent article useful https://exceleratorbi.com.au/finding-the-date-of-the-next-record-in-power-query/

 

I was solving a different problem but the structure of the problem is the same, ie how to match records on different rows and capture the dates. My only different advice would be to sort by NDC then Date as the first step. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

3 REPLIES 3
MattAllington
Community Champion
Community Champion

Glad you liked my book 🙂



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
MattAllington
Community Champion
Community Champion

You might find my recent article useful https://exceleratorbi.com.au/finding-the-date-of-the-next-record-in-power-query/

 

I was solving a different problem but the structure of the problem is the same, ie how to match records on different rows and capture the dates. My only different advice would be to sort by NDC then Date as the first step. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

I sure will!

I would also ask you to sign your book Supercharge Power BI: Power BI is Better When You Learn To Write DAX, but I have the kindle version. It was great and I use it a lot.

I'll update when I try it out.
Thank you!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.