Search code examples
calculated-fieldamazon-quicksight

Filtering a column to use in a calculated field in Quicksight


I have a table like this:

group value
A 2
B 3

I want to create a calculated field that is the value of A divided by the value of B (2/3).

In PowerBI I could create two measures storing the values of A and B and then divide those measures.

How can I do that in Quicksight?


Solution

  • You could do create two sums, one for each group, and then do the final calculation

    Add a calculated field called Sum A

    sumOver(ifelse(group='A', value, null), [], PRE_AGG)
    

    Add a calculated field called Sum B

    sumOver(ifelse(group='B', value, null), [], PRE_AGG)
    

    Add the last calculated field for you final calculation:

    {Sum A} / {Sum B}