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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ronning
Frequent Visitor

Subtracting two date columns in two different tables

Hi, I have a problem with subtracting two date columns from different tables. 

I have tried this.       DATEDIFF(  SUM( 'Table' [Column] ) , SUM( 'Table' [Column]) , DAY ).

But when i drag this measuer into a table it gives me this message.

" An unvalid numerical representation of a datevalue has occoured"

Could this be because thera are some future date in one column that dosent exist in the other ? 

 

 

Thanks

1 ACCEPTED SOLUTION

I found out the problem... It was just to change SUM to MAX.

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Ronning 
If there is a relationship between th etwo tables then if table1 is at the many side and table2 is at the one side and assuming that 'Table1'[Column] is the earlier date and 'Table2'[Column] is the later date then you can use

# Days =
SUMX (
    'Table1',
    DATEDIFF ( 'Table1'[Column], RELATED ( 'Table2'[Column] ), DAY )
)

 

 

I found out the problem... It was just to change SUM to MAX.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.