Forum Discussion
Day Count Business Days Between Two Dates
- 8 years ago
I intended it as a measure.
The culprit is this statement:
Business Day Value = if('Date'[DayOfWeek]="Monday"||
'Date'[DayOfWeek]="Tuesday"||
'Date'[DayOfWeek]="Wednesday"||
'Date'[DayOfWeek]="Thursday"||
'Date'[DayOfWeek]="Friday",
"1",
"0")This statement results in a string of either "1" or "0". Change this to:
Business Day Value = if('Date'[DayOfWeek]="Monday"|| 'Date'[DayOfWeek]="Tuesday"|| 'Date'[DayOfWeek]="Wednesday"|| 'Date'[DayOfWeek]="Thursday"|| 'Date'[DayOfWeek]="Friday", 1, 0)and make sure that the Business Day Value column in your calendar table is of type Whole Number. That should do it.
This is a little out of my depth, as I am still a newbie.
I think the only hang up is the valye that should be in Date[Date Column] - not sure what this should be?
This is my statement for my date table...
Date =
ADDCOLUMNS (
CALENDAR (DATE(2000,1,1), DATE(2025,12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthShortYear",FORMAT([Date], "mmm-YYYY"),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ),
"Week Number", WEEKNUM ( [Date] ),
"Week Number and Year", "W" & WEEKNUM ( [Date] ) & " " & YEAR ( [Date] ),
"WeekYearNumber", YEAR ( [Date] ) & 100 + WEEKNUM ( [Date] )
)
Thanks again!
I used DateColumn since I could not know what name you had chosen for your date column in your calendar. So, replace 'Date'[DateColumn] with 'Date'[Date].
- Anonymous8 years agoNot applicable
Thanks for the continued help...This is the most recent result.
Int neither works a s a Measure or Column, not sure whoch it should be.
Any suggestions?
- erik_tarnvik8 years ago
Solution Specialist
I intended it as a measure.
The culprit is this statement:
Business Day Value = if('Date'[DayOfWeek]="Monday"||
'Date'[DayOfWeek]="Tuesday"||
'Date'[DayOfWeek]="Wednesday"||
'Date'[DayOfWeek]="Thursday"||
'Date'[DayOfWeek]="Friday",
"1",
"0")This statement results in a string of either "1" or "0". Change this to:
Business Day Value = if('Date'[DayOfWeek]="Monday"|| 'Date'[DayOfWeek]="Tuesday"|| 'Date'[DayOfWeek]="Wednesday"|| 'Date'[DayOfWeek]="Thursday"|| 'Date'[DayOfWeek]="Friday", 1, 0)and make sure that the Business Day Value column in your calendar table is of type Whole Number. That should do it.