[HELP] calculating R Squared in AWS QS. Summing over diff between group mean value and raw row value

In my Quick Sight application I have imported dataset with 5 columns:

Bkname,event_name,event_start,turnover,model_turnover

How do I calcualte R squared per bkname like in the picture.

I was able to calcualte Numerator, or SSR in the picture. I have problems with calculating Denominator with calculated fields.

Numerator was calcualted like this
power({turnover} - {model_turnover}, 2)

How can i calcualte denominator? We need to substract row value from mean group value and then sum over squared differences per bkname group.

I was able to get group (bkname) avg, and then in visuals I was able to substract row value (turnover) from mean group turnover value, but I was unable to figure out how to now sum over those differences?

For help, I will be grateful.

Regards
Jernej

Hi Jernej @JernejHenigman ,

I think the following calc will get you what you are looking for.

sum((<measure> - avgOver(<measure>,[<groupField>],PRE_AGG))^2, [<groupField>])

If this doesn’t get you there, due to nuances in your data, please add a sample analysis in Arena with sample data and expected results so that community can help you further.

Regards,
Arun Santhosh
Pr Quick Sight SA