Forum Discussion
WorkingDays Logic Issue
- 4 years ago
Hi, Anonymous ;
You could modify the dax as follows:
WorkingDays = VAR YourDate = IF ( [enddate] = BLANK (), [startdate], [enddate] ) var _count= COUNTROWS ( FILTER ( ADDCOLUMNS ( CALENDAR ( [startdate], YourDate ), "Day of Week", WEEKDAY ( [Date], 1 )), [Day of Week] <> 1&& [Day of Week] <> 7) ) return IF([enddate]=BLANK(),0,_count)The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please try this column expression instead. Replace WD with your actual table name.
WDays =
VAR enddate =
IF ( ISBLANK ( WD[enddate] ), TODAY (), WD[enddate] )
VAR result =
COUNTROWS (
FILTER (
CALENDAR ( WD[startdate], enddate ),
WEEKDAY ( [Date] ) IN { 1, 2, 3, 4, 5 }
)
)
RETURN
IF ( ISBLANK ( WD[enddate] ), 0, result )
Pat
- Anonymous4 years agoNot applicable
Thank you Pat. your expression works but not expected
when there is any future dates in startdate i.e startdate greater than enddate (startdate>enddate) ex:(9/10/2021 > 9/8/2021).
If there is any future dates in startdate make startdate as blank and also for any blanks in either startdate or enddate we replace them with blanks/0 but not with Today()
Please suggest
- Anonymous4 years agoNot applicable
Any suggestions please
- VahidDM4 years agoSuper User
Hi Anonymous
Try to add another condition to mahoneypat measure, if you want to show 0, when startdate is grater than end date or one of those date items is blank:
WDays =
VAR enddate =
IF ( ISBLANK ( WD[enddate] ), TODAY (), WD[enddate] )
VAR result =
COUNTROWS (
FILTER (
CALENDAR ( WD[startdate], enddate ),
WEEKDAY ( [Date] ) IN { 1, 2, 3, 4, 5 }
)
)
RETURN
IF ( WD[startdate]>WD[enddate]||ISBLANK ( WD[enddate] )||ISBLANK ( WD[startdate] ), 0, result )If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos✌️!!