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.
I have two table and one table has start date and another table has end date. I want difference between two dates.
I tried : DATEDIFF(<start_date>, <end_date>, <interval>) in column and Measure but still having problems
Table 1:
Wo | Sdate |
1 | 01/01/2016 |
2 | 02/01/2016 |
3 | 03/01/2016 |
4 | 04/01/2016 |
5 | 05/01/2016 |
6 | 06/01/2016 |
7 | 07/01/2016 |
8 | 08/01/2016 |
9 | 09/01/2016 |
10 | 10/01/2016 |
Table 2:
Wo | Edate |
1 | 01/02/2016 |
2 | 02/02/2016 |
3 | 03/02/2016 |
4 | 04/02/2016 |
5 | 05/02/2016 |
6 | 06/02/2016 |
7 | 07/02/2016 |
8 | 08/02/2016 |
9 | 09/02/2016 |
10 | 10/02/2016 |
I want output something like below,
Wo | Sdate | Edate | Diff |
1 | 01/01/2016 | 01/02/2016 | 31 |
2 | 02/01/2016 | 02/02/2016 | 31 |
3 | 03/01/2016 | 03/02/2016 | 31 |
4 | 04/01/2016 | 04/02/2016 | 31 |
5 | 05/01/2016 | 05/02/2016 | 31 |
6 | 06/01/2016 | 06/02/2016 | 31 |
7 | 07/01/2016 | 07/02/2016 | 31 |
8 | 08/01/2016 | 08/02/2016 | 31 |
9 | 09/01/2016 | 09/02/2016 | 31 |
10 | 10/01/2016 | 10/02/2016 | 31 |
I assume you have built the relationship between two tables already. You can create a column like below:
Diff = 1*('End'[EndDate]-RELATED('Start'[StartDate]))
Regards,
Thank you Simon_Hou-MSFT but in my original data have some blanks in start date column and end date column. so i want there "Not Applicable". is it possible, if yes how?
Here is my original data screenshot. I have two tables - QOrdersAwaitingPart and RPT_ISSUED_PARTS. The tables connected with each other (relationship) * to 1.
QOrdersAwaitingPart table does not have unique column that's why I created unique column using measure which is called LYN. and RPT_ISSUED_PARTS table has unique column which called Work Order ID.
LYN and WorkorderID column combination pf Location-Year-WorkorderNumber.
Now, QOrdersAwaitingPart has start date which is called required date and RPT_ISSUED_PARTS have end date which is called issue date.
I want difference between both dates.
Please find attached images of data and relationship.
I tried it your method but I have having error please check in image
If there's blank values for both start date and end date, you need to apply IF statement for the calculation like:
= IF ( 'End'[EndDate] <> BLANK () && RELATED ( 'Start'[StartDate] ) <> BLANK (), Diff = 1 * ( 'End'[EndDate] - RELATED ( 'Start'[StartDate] ) ), BLANK () )
Regards,
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 |
---|---|
113 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |