Using row value in a calculated field


We are looking to continuously calculate a maximum over a field per partition (multiple dimensions), however not for us in a table calculation but rather to be used on every row. Is there a possibility of doing this in Quicksight currently.

Basically what I see is that it requires the ability to refer in a conditional expression to the row (level) for which the value is currently being calculated.

Identical to what you would do in excel with the following example:

Dimension 1 Dimension 2 Value Output
A 1 10 10
A 2 15 15
B 1 15 15
B 2 10 15
B 3 15 15

Where the formula in the Output column is:

=MAXIFS([Value],[[Dimension 1 ]],[@[Dimension 1 ]],[Dimension 2],“<=”&[@[Dimension 2]])

(note that the @ [@[Dimension 1 ]] in refers to the value of the current row being calculated whereas [[Dimension 1]] refers to the entire column. “<=”&[@[Dimension 2]] is just the way of phrasing the condition applied to Dimension 2 meaning it has to be less than the value of Dimension 2 for the row being calculated.

Any input would be greatly appreciated. Perhaps there is a more “quicksighty” way of doing this. :slight_smile:

Hello @DanielJansson, I think something that could be helpful for you to get your expect result would be the maxOver() function in QuickSight. Do you mind clarifying a bit more on the Output you are expecting? I might be able to put together an example expression for you, but I don’t think I fully understand what the conditions are that you are implementing.

1 Like

Hello @DanielJansson, do you mind following up with the information I requested so I can help guide you towards a solution? Otherwise, if the maxOver function worked or you were able to resolve the issue, would you be able to post the steps you took to find your solution?

Hi Dylan and so sorry for not responding earlier!

I’m not sure I can describe it much better than I did in the previous example. The purpose is measuring the value against historical values that happened before the current row. As I gather based on testing it’s not possible using the maxOver function.

In practice this could be useful if you are e.g. looking to compare the current value against historical max values for the same partition to identify outliers/anomalies. An example us case would be a measuring activity in a scope and see if it either drops or becomes much higher than the historical max values when you have a continuing increase in activity.

Currently we are instead fixing it outside of Quicksight and then feeding it in on row level as raw-data.

Actually maybe the following table would provide some more nuance. This becomes very simplified and often the case is not this easy but imagine that you want to compare the bold-marked rows against the historical max to calculate the distance, in these cases 5/6ths and 3/4ths respectively.

Scope Date Activity Max historic activity
A 2023-05-10 15 15.00
A 2023-05-11 16 16.00
A 2023-05-12 17 17.00
A 2023-05-13 18 18.00
A 2023-05-14 19 19.00
A 2023-05-15 20 20.00
B 2023-01-02 15 15.00
B 2023-01-03 20 20.00
B 2023-01-04 25 25.00
B 2023-01-05 30 30.00
B 2023-01-06 28 30.00
B 2023-01-07 29 30.00
B 2023-01-08 30 30.00
B 2023-01-09 27 30.00
B 2023-01-10 5 30.00
B 2023-01-11 30 30.00
B 2023-01-12 40 40.00
B 2023-01-13 30 40.00
B 2023-01-14 35 40.00
B 2023-01-15 10 40.00
B 2023-01-16 38 40.00
B 2023-01-17 40 40.00
B 2023-01-18 40 40.00


Hi @DanielJansson
could you please check

runningMax(sum(Activity),[Date ASC], [Scope])