Use Power Query to Compare Database Records

Level: Intermediate

I was helping a user on this week. The user had a list of service desk tickets for multiple customers and the requirement was to identify when a customer opened a second new ticket within 7 days of closing a previous ticket.  This is not an uncommon scenario so I thought it would make a good blog article.


One of the challenges that new users have when using Power BI is to decide if they should use Power Pivot (DAX modelling) or Power Query (PQL shaping) to solve each problem.  And if the answer is DAX, then they also need to decide if it should be a measure or calculated columnThere is no one single correct answer to these questions and it always depends on the circumstances.  I generally recommend to shape your data properly prior to loading to Power Pivot, that way the DAX formulas are easier to write and the reporting database will be more performant.   I looked at the options for this problem and decided to use Power Query to shape the data before loading.  Power Pivot and DAX are not really designed to do ordinal row comparisons, so this task is better handled with Power Query.

For this particular problem I thought I would produce a video that demonstrates one way in which this problem can be solved.  Here it is.

Learn to be a Power Query Expert

If you want to fast track your learning so you can leverage all the power of Power Query, take a look at my self-paced online Power Query training course.  You can also watch some free sample Power Query training videos here to get a feel about how you are going to learn.

This training has over 7 hours of video explaining concepts like this.  Once you know how, you will be able to save time and do fantastic things you never dreamed possible as a Power Query expert.



  1. Sweet! Great trick and it solve (I think at least) a problem I have been scratching my head about for some time. (“Rouge” record in cvs file that belongs with the one above it in the middle of the record.)

    • I assume you can use the same approach I describe in the article. first sort the table appropriately and then fetch the previous end date from the previous record into the current record. From there, just check if there is an overlap between the start date of the current record with the end date of the previous record.

  2. How to load DBF files? Any suggestions? As I understand, as of Excel 2016 file extension support was removed.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ten Things I Wish I Knew When I Started With Power Pivot.   Learn  Without The Pain!