How to Find New Appointments Using Multiple Columns in Power Query
Question details
The user needs to compare rolling appointment reports to label records as 'New' or 'Existing' based on multiple columns, such as patient ID and appointment date.

- Product
- Microsoft Excel (Power Query)
- Device & OS
- not provided
- Scenario
- Comparing appointments on a current day with corresponding appointments in the two previous daily reports to check for new entries.
- Observed behavior
- The goal is to mark an appointment as 'New' if it was absent from the previous two reports, and 'Existing' otherwise, using Power Query M code instead of relying on Microsoft 365 specific formulas.
Ensure your dataset contains properly formatted columns for patient IDs, appointment dates, and report generation dates before applying Power Query transformations.
Use Power Query Grouping and Custom Columns
Apply M code transformations to group records and dynamically compare report dates.
By grouping your data by Patient ID and Appointment Date, you can isolate specific appointment instances. Using M code, you can then evaluate whether an appointment existed in prior reports by comparing the report dates.
Open the Power Query Editor, select your report-date column, and change its data type to Date to ensure accurate chronological sorting.
Use the Advanced Editor to define a 'firstReportDate' variable using the List.Min function. This provides a baseline reference to determine historical presence.
Select both the Patient ID and Appointment Date columns. Right-click the header and choose 'Group By' to consolidate the records into grouped tables.
Create a Custom Column within the grouped data that checks if the appointment was absent in the two previous reports. Set the logic to output 'New' if absent, and 'Existing' if present.
Remove the temporary grouping columns, click the expand icon on your custom column to restore the standard table view, and sort the output as needed.

Alternative: Use Power Pivot and DAX
If Power Query M code proves too complex for list comparisons, DAX formulas in Power Pivot offer an effective alternative.
Handle complex data comparisons easily with WPS Office
While advanced Power Query M scripting is specific to Microsoft Excel, you can often achieve similar multi-column data comparisons—like finding new or existing records—using standard array formulas and advanced filtering in WPS Spreadsheet, a free, fast, and highly compatible alternative to Microsoft Office.

Frequently Asked Questions
Can I compare multiple columns in Power Query without Microsoft 365?
Yes, Power Query is available as a standalone add-in for older versions like Excel 2010 and 2013, and is built natively into Excel 2016 and later versions as 'Get & Transform', entirely independent of a Microsoft 365 subscription.
How do I group by multiple columns in Power Query?
Select the columns you want to group by (e.g., Patient ID and Appointment Date) while holding down the Ctrl key, right-click one of the highlighted headers, and choose 'Group By' from the context menu.
Why use List.Min for date comparisons in Power Query?
Using List.Min allows you to dynamically find the earliest date in your grouped report-date list. This provides a baseline reference to determine whether an appointment existed in a previous reporting cycle.
Are DAX and Power Query the same thing?
No. Power Query uses M code to extract, transform, and load (ETL) data before it reaches the spreadsheet. DAX (Data Analysis Expressions) is a formula language used in Power Pivot to analyze and calculate data that has already been loaded into the Data Model.




