Hello QuickSight Community,
I’ve downloaded a template from a QuickSight account using describe-template-definition
and I want to use that to re-create it in another account. One of the issues I’m encountering is that some of the ConditionalFormattingOptions
on Visuals fail because the expression is invalid.
There are two different cases in which this happens:
- The expression contains a logical operator like
AND
:
{
"ConditionalFormattingOptions": [
{
"PrimaryValue": {
"TextColor": {
"Solid": {
"Expression": "AVG({latest_proficiency}) < 50",
"Color": "#DE3B00"
}
}
}
},
{
"PrimaryValue": {
"TextColor": {
"Solid": {
"Expression": "(AVG({latest_proficiency}) >= 50) AND (AVG({latest_proficiency}) <= 74)",
"Color": "#FF8700"
}
}
}
},
{
"PrimaryValue": {
"TextColor": {
"Solid": {
"Expression": "AVG({latest_proficiency}) >= 75",
"Color": "#2CAD00"
}
}
}
}
]
}
In the UI, the conditional formatting for an analysis created from this template (successfully) shows up as this:
- The expression contains a calculated field with a custom aggregation formula:
{
"ConditionalFormattingOptions": [
{
"PrimaryValue": {
"TextColor": {
"Solid": {
"Expression": "{Proficiency Improvement %} <= 0",
"Color": "#DE3B00"
}
}
}
},
{
"PrimaryValue": {
"TextColor": {
"Solid": {
"Expression": "{Proficiency Improvement %} > 0",
"Color": "#2CAD00"
}
}
}
}
]
}
The errors I’m seeing are similar to this one:
Error while parsing conditional formatting expression: {Proficiency Improvement %} <= 0. Error : Invalid conditional formatting expression.
Following are the valid expression formats for different comparison methods when value field and target value field are defined.
DIFFERENCE comparison method: SUM({ValueField})-COUNT({TargetValueField}) >= 100,
PERCENT comparison method: SUM({ValueField})/nullIf(COUNT({TargetValueField}),0) < 100,
PERCENT_DIFFERENCE comparison method: (SUM({ValueField})/nullIf(COUNT({TargetValueField}),0))-1 = 100.
Following are the valid expression formats for different comparison methods when value field and trend group field are defined.
When trend group field is other than date and time type field,
DIFFERENCE comparison method: difference(SUM({ValueField}),[SUM({ValueField}) DESC],1,[]) = 100,
PERCENT comparison method: percentDifference(SUM({ValueField}),[SUM({ValueField}) DESC],1,[])+1 <= 100,
PERCENT_DIFFERENCE comparison method: percentDifference(SUM({ValueField}),[SUM({ValueField}) DESC],1,[]) > 100.
When trend group field is date and time type field,
DIFFERENCE comparison method: difference(SUM({ValueField}),[{TrendGroupField} DESC],1,[]) = 100,
PERCENT comparison method: percentDifference(SUM({ValueField}),[{TrendGroupField} DESC],1,[])+1 <= 100,
PERCENT_DIFFERENCE comparison method: percentDifference(SUM({ValueField}),[{TrendGroupField} DESC],1,[]) > 100.
Aggregation functions and comparison operator can be any of the accepted functions or operator respectively.
The problem is that describe-template-definition
return a JSON object that is not accepted by create-template
. The template works fine when creating analyses/dashboards from it.
Thanks,
Adrian