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.
Hi all,
So, I am trying to calculate the difference between two different date columns in two separate tables.
Essentially, I have 2 tables that look like this (sorry for the poor screenshot lol)
So, I am trying to calculate the difference between these dates in terms of months. But I cannot figure out how to actually calculate it using DATEDIFF. I can't have a relationship between the two dates because they are completely different. I would think to create a new column within the shipped date table and use DATEDIFF(Shipped Date[Shipped Date], Action Date[List], MONTH) but it refuses to accept it, saying it cannot find Action Date[List] or that there needs to be a relationship between them.
I would appreciate any help!
Solved! Go to Solution.
Hi @Anonymous ,
In your scenario, it is not supported to create a relationship between two tables because they don't have a same column to create relationship, at least you need to have a id column or other.
If you want to calculate the DATEDIFF row by row, you can create an index column for two tables like below:
Then we can create a relationship between these two index column, after that we can create a calculated column using the following DAX query:
Column = CALCULATE(DATEDIFF(MIN(Table1[Shipped Date]),MIN(Table2[Action Date]),MONTH))
The result will like below:
Best Regards,
Teige
Hi @Anonymous ,
In your scenario, it is not supported to create a relationship between two tables because they don't have a same column to create relationship, at least you need to have a id column or other.
If you want to calculate the DATEDIFF row by row, you can create an index column for two tables like below:
Then we can create a relationship between these two index column, after that we can create a calculated column using the following DAX query:
Column = CALCULATE(DATEDIFF(MIN(Table1[Shipped Date]),MIN(Table2[Action Date]),MONTH))
The result will like below:
Best Regards,
Teige
That makes more sense. I have a string for each customer, am I not able to relate that between the two?
in your shipped date table, what date from the other table would you be looking to subtract? Seems like there should be a few more columns to each of these tables.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
78 | |
75 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |