Hi @nw2this, if you want to calculate percent rank within a group without using the built-in summary functions, you indeed might face some limitations. QuickSight’s calculated fields are quite powerful, but they don’t directly support SQL window functions which are typically used for this kind of calculation. However, there are a few ways you can approach this problem:
In Amazon QuickSight, if you want to calculate percent rank within a group without using the built-in summary functions, you indeed might face some limitations. QuickSight’s calculated fields are quite powerful, but they don’t directly support SQL window functions which are typically used for this kind of calculation. However, there are a few ways you can approach this problem:
1. Using SQL in SPICE Datasets
If your dataset is in SPICE (Super-fast, Parallel, In-memory Calculation Engine), you can use the QuickSight’s SQL editor for datasets to apply SQL transformations including window functions. Here’s how you can use SQL to calculate percent rank within states:
- Go to the dataset preparation page and select your dataset.
- Open the SQL editor. This option is available only for SPICE datasets.
- Use a SQL query like the following to create a new dataset with the percent rank calculation:
SELECT *,
PERCENT_RANK() OVER (PARTITION BY state ORDER BY your_number_field) AS PercentRank
FROM your_table_name
- Create a new analysis using this transformed dataset.
This approach leverages QuickSight’s SQL capability to apply advanced analytics like window functions directly within QuickSight.
2. Calculating Outside QuickSight
As you suggested, another method is to perform the calculation outside of QuickSight, such as in a database or in Excel, and then import the dataset with the percent rank already calculated. This method might be easier if you are comfortable with SQL or Excel and have access to these tools to preprocess your data.
3. Custom Calculations with QuickSight Functions
If neither of the above options suits you and if your data set isn’t too large, you could potentially create a cumbersome workaround using QuickSight’s available functions, but this wouldn’t be straightforward or efficient as using SQL.
Recommendations:
- Using SQL in QuickSight SPICE: This is likely the most straightforward method if your data is in SPICE and you’re comfortable with SQL.
- Preprocessing the Data: If your dataset is large or if the SQL capabilities in QuickSight do not meet your needs, preprocessing the data externally (in a database or Excel) would be a robust approach.
Each method has its trade-offs regarding ease of use, performance, and flexibility, so the choice depends on your specific needs and environment. If you haven’t used the SQL functionality in QuickSight yet, it’s worth exploring, especially for advanced data transformations like this.
We hope this solution worked for you. Let us know if this is resolved. And if it is, please help the community by marking this answer as a “Solution.” (click the check box under the reply)