In this article, I will go over how to build a date dropdown menu that filters your data based on specific date ranges (ie last 7 days, MTD, etc):
The data we will be using for this example looks like:
The main function we will need to use to build this is a Switch statement, which will allow us to take into account each case
The first thing we need to do is build our User Input Control with a Control Type Drop-Down List
Then, we will need to set a variable for this User Input Control. I called mine "dates"
The next step we will have to do is to set our values for the user input control in the form of an Array
If I want to filter for last 7 days, last 30 days, month to date and last month, my values will look something like this:
And my labels will look like this:
Now that we have built our User Input Control, we can begin to build our Switch statement which goes into the series of the bar/line chart or the current value of the gauge.
The Switch statement has 3 parameters; the data, the case and the value:
For this statement, the data will be the variable we set with the User Input Control
The cases will be the data within the array for the values of the User Input Control
The value is our Between statement that filters the data based on date