In this blog, I will take through how to create custom dates for yearly, monthly, quarterly, Weekly, Daily, Last month, Last week Yesterday.
Step 1 – Create Parameters for Date Range:
Create a parameter with a data type of string and create list for the above dates. Once these are created, right-click on each one and choose “Show Parameter Control”.

Step 2 – Create Calculated field:
-
Create a calculated field that uses Datename() function. The Datename() function returns a part of the given date as a string part and let us name that calculated field as Date.

-
To compute “last month”,” Yesterday”& “Last week” .First of all, we need to find the latest date . This can be achieved by the following calculation:
-
Now we can use date diff of month for the max-date and order date to find the difference between the two dates.If it returns a value of 0 then return the latest month date.

-
Similarly, we can create calculated fields for Yesterday , Last week as above calculation by replacing “week” and “days” in the datediff function
Step 2 – Create view:
Drag the Date and Segment field from dimension and place Date in columns and Segment in rows and sales in rows.



