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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
queryuser
Helper I
Helper I

Compare dates between two related tables via a calculated column

Hello Everyone!

 

Your advice Power BI  is needed. I am struggling to create a new column (green) that would indicate if the dates have changed between Old Date & New Date irrespective of the timestamp (snapshot of data). Tables have a Many to Many relationship based on Key (Document Nr.)

 

Merging them is not an option because left table is incrementally refreshed containing historical & today's timestamp of data while table on the right only today's timestamp (snaphot) of data.

 

queryuser_1-1651218342360.png

 

The result shall be a new column saying if dates:

Did not change, moved within month, moved to next or previous month.

And if no document nr. matches (missing in left table (for timestamps before today) but present in the right one) then new order

 

Many thanks,

 

 

1 ACCEPTED SOLUTION
queryuser
Helper I
Helper I

Hi I found the solution, in the end it was the M Query. The reason for not being able to merge the tables was that Table A & Table B contained the same data for Today. So to solve the issue I did the following:

 

1. Add a custom column to Table A saying (if [TimeStamp] = Date.From(DateTime.LocalNow()) then "Today" else [TimeStamp]

 

2. Filtered out Today from the Table A

3. Merged table A Key with table B Key

4. Got new dates 

5. Added a column and added the rules based on date differences

 

View solution in original post

3 REPLIES 3
queryuser
Helper I
Helper I

Hi I found the solution, in the end it was the M Query. The reason for not being able to merge the tables was that Table A & Table B contained the same data for Today. So to solve the issue I did the following:

 

1. Add a custom column to Table A saying (if [TimeStamp] = Date.From(DateTime.LocalNow()) then "Today" else [TimeStamp]

 

2. Filtered out Today from the Table A

3. Merged table A Key with table B Key

4. Got new dates 

5. Added a column and added the rules based on date differences

 

amitchandak
Super User
Super User

@queryuser , a new column in table B

 

maxx(filter(TableA, TableB[Document Nr] = TableA[Document Nr] &&   TableB[timestamp] = TableA[timestamp] ), TableA[Old date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

Thank you for the input. Would say that the new column shall be in Table A since it is a table with historical data. Doing it for Table B would not lead to the desired result.

 

Just tried it for Table B and it brings up blank values - for the Historical data from Table B
After reversing the formula for Table A it seems to not work anyomere

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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