Forum Discussion
Power BI DATESBETWEEN
I am using DATESBETWEEN Dax formula to create a column(see below) . I have a Date Table. The formula is returning blanks for all rows except where the Fully approved date is blank. Any thoughts on what I may be doing incorrectly?
| BUD1 | Identifier | Today's date | Approved Date | Wkdays w/o Holidays col |
| GLOBAL | 1 | 6/21/2022 0:00 | 3/1/2022 0:00 | |
| Operations | 2 | 6/21/2022 0:00 | 2/22/2022 0:00 | |
| Global | 3 | 6/21/2022 0:00 | 3/7/2022 0:00 | |
| Regional | 4 | 6/21/2022 0:00 | 3/3/2022 0:00 | |
| Operations | 5 | 6/21/2022 0:00 | 3/3/2022 0:00 | |
| Static | 6 | 6/21/2022 0:00 | 2/18/2022 0:00 | |
| GLOBAL | 7 | 6/21/2022 0:00 | 139 | |
| Regional | 8 | 6/21/2022 0:00 | 5/3/2022 0:00 | |
| Static | 9 | 6/21/2022 0:00 | 139 |
Hi Anonymous ,
In the DATESBETWEEN function -"DATESBETWEEN(<Dates>, <StartDate>, <EndDate>)", the second parameter is start date and the third parameter is end date. If the start date is biger than the end date, it will return blank.
You can modify the formula like this:
Wkdays w/o Holidays col = IF ( ISBLANK ( MAX ( 'Open pending Requisitions'[Approved Date] ) ), CALCULATE ( COUNTROWS ( 'Dates' ), DATESBETWEEN ( 'Dates'[Date], MAX ( 'Open pending Requisitions'[Today's date] ), MAX ( 'Open pending Requisitions'[Approved Date] ) ), FILTER ( Dates, Dates[IsWorkDay] = TRUE ), ALLSELECTED ( 'Dates'[Date] ) ), CALCULATE ( COUNTROWS ( 'Dates' ), DATESBETWEEN ( 'Dates'[Date], MAX ( 'Open pending Requisitions'[Approved Date] ), MAX ( 'Open pending Requisitions'[Today's date] ) ), FILTER ( Dates, Dates[IsWorkDay] = TRUE ), ALLSELECTED ( 'Dates'[Date] ) ) )Here, the rows without Approved Date will retain the same result, other rows will get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- v-yanjiang-msft
Community Support
Hi Anonymous ,
In the DATESBETWEEN function -"DATESBETWEEN(<Dates>, <StartDate>, <EndDate>)", the second parameter is start date and the third parameter is end date. If the start date is biger than the end date, it will return blank.
You can modify the formula like this:
Wkdays w/o Holidays col = IF ( ISBLANK ( MAX ( 'Open pending Requisitions'[Approved Date] ) ), CALCULATE ( COUNTROWS ( 'Dates' ), DATESBETWEEN ( 'Dates'[Date], MAX ( 'Open pending Requisitions'[Today's date] ), MAX ( 'Open pending Requisitions'[Approved Date] ) ), FILTER ( Dates, Dates[IsWorkDay] = TRUE ), ALLSELECTED ( 'Dates'[Date] ) ), CALCULATE ( COUNTROWS ( 'Dates' ), DATESBETWEEN ( 'Dates'[Date], MAX ( 'Open pending Requisitions'[Approved Date] ), MAX ( 'Open pending Requisitions'[Today's date] ) ), FILTER ( Dates, Dates[IsWorkDay] = TRUE ), ALLSELECTED ( 'Dates'[Date] ) ) )Here, the rows without Approved Date will retain the same result, other rows will get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.