Using CloudFormation to add dataset calculated fields

@jnkline - Thank you for the detailed response. I hear you. Quick Sight does not let you define or preserve dataset-level calculated fields within CloudFormation templates. Calculated fields added manually get wiped out on any CFT-driven dataset update, and automating their recreation is not natively supported.

Suggested Workaround -

Use the Quick Sight API (via boto3 or CLI) to script calculated field creation by including them as CalculatedColumn objects in your dataset definition. Store these definitions in configuration files or source control, and run a post-CFT stack update script that applies them consistently across environments. Alternatively, implement calculated fields in your database views or SQL queries to make them part of the physical schema, preserving them automatically during CFT updates.

This approach is not yet fully automated by AWS but is the practical workaround used in many multi-environment Quick Sight setups.

Here are key resources and guidance for scripting and managing Quick Sight dataset calculated fields:

  1. Quick Sight API supports creating/updating datasets with calculated fields via CalculatedColumn objects in the CreateDataSet or UpdateDataSet API calls. You specify a unique ColumnId and an expression formula to recreate calculated fields programmatically after CloudFormation changes:

  2. Quick Sight boto3 create_data_set API

  3. Quick Sight boto3 docs overview

Just fyi - https://community.amazonquicksight.com/t/dashboard-creation-fails-with-error-code-contextual-unknown-symbol-during-validation/9250/2

If nothing works, I would suggest you to raise a support ticket. You could look to opening up a case with AWS and see if they can provide a solution or other workarounds.

Here are the steps to open a support case . If your company has someone who manages your AWS account, you might not have direct access to AWS Support and will need to raise an internal ticket to your IT team or whomever manages your AWS account. They should be able to open an AWS Support case on your behalf. Hope this helps!

Thank you,

Shravya