-
Book Overview & Buying
-
Table Of Contents
Tabular Modeling with SQL Server 2016 Analysis Services Cookbook
By :
The WEEKDAY function returns the day of the week as an integer. The week starts with Sunday as 1. Using this function, you can include information in your model to indicate workdays and weekends. Also you can create analysis that reviews trends on performance based on the day of the week. For example, do more crashes occur on Fridays than Tuesdays?
Open the Model.bim to the Calc_Date_T table.
In the measure creation area, click on an empty cell to create a measure to return the day of the week as an integer:
DayofWeek:=WEEKDAY("1/1/2016")

January 1st 2016 is a friday and the result returned is a 6.
To make this more beneficial to users, you can convert the number to the name of the day:
DayofWeekName:=FORMAT(WEEKDAY("1/1/2016"),"DDDD")

This function takes a date as an argument and returns the day of the week as an integer. You can use this function to find dates that are weekday values (2-6) and weekend values...