Hello,
I encountered this issue a month ago and I think I found a solution thanks to a recent QuickSight update. (See here for details: Automate and accelerate your Amazon QuickSight asset deployments using the new APIs | AWS Big Data Blog)
Context:
I am using CloudFormation Templates to create an Analysis that contains a Date Range Filter with Rolling Date values. I did not explicitly use DateTime parameters for the rolling dates, but this solution may be applicable for both Filter Controls and Parameter Controls.
Solution:
At the time of this response, Date Ranger Filters and Date Time Parameters using ‘Rolling Dates’ require an ‘expression’ to set a value. However, AWS Documentation still does not specify what value ‘expression’ requires. Turns out, it is basically a ‘Calculate Field’ Expression. This does not mean you create a Calculated Field, rather you will create an expression with two Functions that are used when creating a Calculated Fields.
Use this as the expression value: ‘addDateTime(amount, period, truncDate(period, date))’
If you are like me and are new / unfamiliar with Calculated Field Functions, I provided two links below that should help explain what each argument requires:
- addDateTime - Amazon QuickSight
- truncDate - Amazon QuickSight
Example - scenario:
In an analysis sheet, I want to create a Date Range Filter with Rolling Dates that reflects daily data from the previous week.
Example - Filter Control:
ExampleAnalysis:
. . .
FilterGroups:
- CrossDataset: SINGLE_DATASET
FilterGroupId: <your ID>
Filters:
- TimeRangeFilter:
Column:
ColumnName: <your date column name>
DataSetIdentifier: <your DataSet ID>
FilterId: <your filter id>
IncludeMaximum: true
IncludeMinimum: true
RangeMaximumValue:
RollingDate:
Expression: "addDateTime(-1, 'SS', truncDate('WK', now()))" # Expression Value = End Of Previous Week
RangeMinimumValue:
RollingDate:
Expression: "addDateTime(-1, 'WK', truncDate('WK', now()))" # Expression Value = Start Of Previous Week
NullOption: NON_NULLS_ONLY
TimeGranularity: DAY
ScopeConfiguration:
SelectedSheets:
SheetVisualScopingConfigurations:
- Scope: ALL_VISUALS
SheetId: <your sheet id>
. . .
FilterControls: # Creates filters for Filter groups without parameter usage
- RelativeDateTime:
FilterControlId: !Join ["-", [Range, !Ref FilterControlId3, !Ref SheetId5, !Ref AnalysisID]]
SourceFilterId: !Join ["-", [Range, !Ref FilterId3, !Ref SheetId5, !Ref AnalysisID]]
Title: "Choose Date Range"
Example (Parameter Control):
ExampleAnalysis:
. . .
FilterGroups:
- CrossDataset: SINGLE_DATASET
FilterGroupId: <your ID>
Filters:
- TimeRangeFilter:
Column:
ColumnName: <your date column name>
DataSetIdentifier: <your DataSet ID>
FilterId: <your filter id>
IncludeMaximum: true
IncludeMinimum: true
RangeMaximumValue:
Parameter: EndDate
RangeMinimumValue:
Parameter: StarDate
NullOption: NON_NULLS_ONLY
TimeGranularity: DAY
ScopeConfiguration:
SelectedSheets:
SheetVisualScopingConfigurations:
- Scope: ALL_VISUALS
SheetId: <your sheet id>
. . .
ParameterDeclarations
- DateTimeParameterDeclaration:
DefaultValues:
RollingDate:
Expression: "addDateTime(-1, 'WK', truncDate('WK', now()))" # Expression Value = Start Of Previous Week
Name: StartDate
TimeGranularity: DAY
- DateTimeParameterDeclaration:
DefaultValues:
RollingDate:
Expression: "addDateTime(-1, 'SS', truncDate('WK', now()))" # Expression Value = End Of Previous Week
Name: EndDate
TimeGranularity: DAY
...
ParameterControls: # Creates a filters for Filter groups with parameter usage
- DateTimePicker:
ParameterControlId: <your Param Control ID>
SourceParameterName: StardDate
Title: "Choose Start Date"
- DateTimePicker:
ParameterControlId: <your Param Control ID>
SourceParameterName: EndDate
Title: "Choose End Date"
I hope this helps. I cannot guarantee the “Control Parameter” section is 100% correct (ex. typos), but I just hope this can be a jumping point to get people further along.