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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
game1
Helper II
Helper II

Subtract the 3 dates from different tables

Hello,

I have Table2[dateBefore], Table1[dateBegin] and Table1[dateEnd].

So, I need to subtract the 3 dates, so I can have the result in DAYS:  so something like Table2[dateBefore] - Table1[dateEnd] - Table1[dateBegin] 

So, I create a new coloumn call DatesDiff = DATEDIFF(Table2[dateBefore], Table1[dateBegin], DAY) + DATEDIFF(Table2[dateBefore], Table1[dateEnd], DAY)

But the new coloumn call DatesDiff is create in Table1, so I can have acces to Table2[dateBefore].

How can I do if I want to subtract column from differents tables?  I need to have an ID common to the 2 tables to do that?

Can I do that using join?

Please, give complete answer.

1 REPLY 1
wdx223_Daniel
Super User
Super User

if all the IDs in those tables are unique, you can try to add a new step in table1

NewStep=Table.AddColumn(Table1,"DateDiff",each let a=Table2{[ID=[ID]]}?[dateBefore]? in a=null then null else Duration.Days(a-[dateEnd]-[dateBegin]))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors