I have a table that contains the “Revenue” column.
I need to show a SUM of Revenues only of this quarter.
I need a filter that would dynamically adapt to quarter and to the current year.
I haven’t tested this, but this should work:
- Create an option set called Quarter, add an attribute for start_date and end_date both of type date.
- Add options Q1, Q2, Q3, Q4.
- Add their attributes for the start and end dates of their respective quarters. (any year will do as we’ll see in steps 7 and 8).
- On your page add a custom state for Current_Quarter of type Quarter.
- Add another custom state called Quarter_Date_Range of type date range.
- On page load set Current_Quarter to the actual current quarter as follows by creating 4 actions:
1st: Set Current_Quarter to Q1
2nd: Set Current to Q2 only when current date’s month >=4
3rd: Set Current to Q3 only when current date’s month >=7
4th: Set Current to Q4 only when current date’s month >=10 - Create another action after step 6’s action to set Start of Quarter_Date_Range to Current_Quarter’s start date and then another action immediately after to change years to current year. Something like this.
- Repeat step 7 for Current_Quarter’s end date.
You now have a Current_Quarter date range that you can run your revenue reports on.
2 Likes