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 would like to count the number of days between two date fields: 'datereceived' and 'datedulymade'. I tried to use the DATEDIFF function, BUT - some of the corresponding dates are the same (e.g. number of days between dates=0) which seems to cause an error, ALSO, some of the 'datedulymade' rows are blank (i.e. process not complete)
I have tried to nest an IF statement in to the DATEDIFF field however the blank date fields seem to be causing an error of the format type and I I am unsure how to get around this.
Perhaps use ISBLANK in your IF statement to check for that boundary condition?
https://msdn.microsoft.com/en-us/library/ee634204.aspx
@NRW_admin1 You can use DATEDIFF when the dates are the same (see picture below) but you can't have blanks or negative values (to deal with negatives see link at the bottom)
Num of Days = IF ( ISBLANK ( 'Table'[Made] ), BLANK (), DATEDIFF ( 'Table'[Received], 'Table'[Made], DAY ) )
Also see response here... (although this doesn't deal with Blank may give some ideas)
Problem solved, combined with guidance in the link. Many thanks 🙂
@NRW_admin1
It is great to hear the problem got solved.
It would be greatly appreciated of you if you can post the solution and accepting it as solution can help the people who would have the same problem to find the answer quickly. 🙂
To workaround the blank values in the date column, I created a new column with a false date (01/01/2025) for all the blanks:
false date (duly made) = IF(ISBLANK(permitapplicationSet[nrw_dulymadedate]), DATE(2025, 1, 1), permitapplicationSet[dulymadedate])
Then I used the formula to calculate number of days taken to duly make the applications:
Days to duly make = SWITCH(TRUE(), permitapplicationSet[datereceived]<permitapplicationSet[dulymadedate], DATEDIFF(permitapplicationSet[datereceived], permitapplicationSet[dulymadedate], DAY), permitapplicationSet[datereceived]>permitapplicationSet[dulymadedate], -1*DATEDIFF(permitapplicationSet[dulymadedate], permitapplicationSet[datereceived], DAY), 0)
This actually returned a blank for all rows with the false date. Which is great although I wasn't expecting that result!
Can you post the formula's that you have tried?
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 |
---|---|
111 | |
94 | |
82 | |
66 | |
59 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |