From the course: SQL Server Analysis Services

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Writing DATESBETWEEN measures

Writing DATESBETWEEN measures - SQL Server Tutorial

From the course: SQL Server Analysis Services

Writing DATESBETWEEN measures

- [Instructor] Here, we will use the DATESBETWEEN function to create our own week to date, as there isn't a time-intelligence function to do this. DATESBETWEEN is similar to PARALLELPERIOD, where you define a range of dates to use in the calculation. In this measure, we're going to be also introducing the use of variables. Let's start by creating our new measure and call it week-to-date sales and colon. Let's give ourselves some more, equals, space by clicking on this double arrow so that we have more room to work here. We're going to add some comments after our shift-enter, because a dash, two dashes, equal comments. We'll just add ourself a line here. I'm going to use shift-enter again and create our first variable. Our first variable is going to be started by the word var. You can choose to capitalize it or not, your call. And we'll call this CurrentDate. After CurrentDate, put an equal sign and give it a value. We're…

Contents