### Scenario 18: Day, Week to date, Month to date, Quarter to Date and year to date data filtering using parameter selection

For example. today is 12th May 2018.
When you select Day then we must show 12th May 2018 data.
When you select Week, we must show 5th May 2018 to 12th May 2018, i.e. One-week data.
When you select Month, we must show 11th Apr 2018 to 12th May 2018
similarly, for quarter and year

With help of single calculation, we can filter data for above requirement.

I created two parameters.

“Date selection” to Select Date (we don’t have current date data, so I am selecting date and filtering Day, week, MTD, QTD and YTD with respect to that date.)

“Time Period Selection” to select Day, Week, Month, Quarter or Year to date.

Finally, I written calculation shown below to filter data

“Time Period Selection Filter”

Case [Time Period Selection]
when 'Day' then
If [Order Date] = [Date Selection] then TRUE else FALSE end
when 'Week' then
if [Order Date] >= dateadd('week',-1,[Date Selection]) and [Order Date] <= [Date Selection] then TRUE else FALSE end
when 'Month' then
if [Order Date] >= dateadd('month',-1,[Date Selection]) and [Order Date] <= [Date Selection] then TRUE else FALSE end
when 'Quarter' then
if [Order Date] >= dateadd('quarter',-1,[Date Selection]) and [Order Date] <= [Date Selection] then TRUE else FALSE end
when 'Year' then
if [Order Date] >= dateadd('year',-1,[Date Selection]) and [Order Date] <= [Date Selection] then TRUE else FALSE end
END

Drag this calculation field “Time Period Selection Filter” to filter shelf and select “True”

By changing parameter and date selection you can see expected results.