I am currently trying to create a dynamic charting system within Google Sheets for a tracker. Right now, the first chart is how I have it set up, pointing to the sheet "History." When I select something in the drop-down menu on the Dashboard, it updates the chart to show the values based on the date.
Here is how I want to change it: I want to create a separate date column that gets updated based on a second drop-down menu. This second menu would let me select date ranges such as "Last 30 days" or "This year" or "7 days" or whatever custom date ranges I want to configure. This would make it so the data that gets populated in columns A and B in the History Test tab would be updated based on the 2 selection criteria. So I could select Value 3 and 7 days or Value 2 and 1 year and the chart would automatically update based on those selections. I am sure I am over complicating it but hopefully I am just missing a key formula that lets met do this easily.
D21
(options are Last 30 days
, 7 days
and Last year
).B21
are filtered and retrieved by the same formula.B21
, is returned with a QUERY which uses SUBSTITUTE, ADDRESS and MATCH, as explained, for example, here.=IF(Dashboard!D21="Last 30 days",
FILTER({QUERY(D:F,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH(Dashboard!B21,D1:F1,0)+3,4),1,"")),C:C},DAYS(TODAY(),C:C)<=30),
IF(Dashboard!D21="7 days",
FILTER({QUERY(D:F,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH(Dashboard!B21,D1:F1,0)+3,4),1,"")),C:C},DAYS(TODAY(),C:C)<=7),
IF(Dashboard!D21="Last year",
FILTER({QUERY(D:F,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH(Dashboard!B21,D1:F1,0)+3,4),1,"")),C:C},DAYS(TODAY(),C:C)<=365))))