# WoW calculation

**URL:** <https://community.amazonquick.com/t/wow-calculation/5878>\
**Category:** Q&A\
**Tags:** calculations, quick-sight\
**Created:** [September 7, 2022, 8:28pm UTC](https://community.amazonquick.com/t/wow-calculation/5878 "2022-09-07T20:28:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iti\_shri](https://avatars.discourse-cdn.com/v4/letter/i/e274bd/32.png) [@iti\_shri](https://community.amazonquick.com/u/iti_shri)\
**Post date:** [September 7, 2022, 8:28pm UTC](https://community.amazonquick.com/t/wow-calculation/5878/1 "2022-09-07T20:28:08Z")

</div>

We need to calculate a week over week % change, but we want to compare the current week numbers with average of past three weeks.Is there a function that can help achieve this.

Example week 1 = 34  
week 2 = 30  
week 3= 36  
week 4 = 45

Calculation needed is % change between 45 and average of (34+30+36)

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [September 7, 2022, 11:19pm UTC](https://community.amazonquick.com/t/wow-calculation/5878/2 "2022-09-07T23:19:34Z")

</div>

Hey there!

I think I’ve figured it out. Let me know if this works for you. I am using the count of sessions, but substitute your measure in.

First let’s make a calculation to get the avg of your calculations based on the weeks.

avgOverSession= count({session\_id})/distinct\_count(truncDate(‘WK’,{event\_timestamp}))

Then I am going to split your timestamp field into two categories. Whether it is this week or the last three weeks. For this, I am truncating to the week. Feel free to play with taking the truncDate off if the calculation is not fully correct.

is last three weeks = ifelse(dateDiff(truncDate(‘WK’,{event\_timestamp}),truncDate(‘WK’,now()),‘WK’)\<=3 AND dateDiff(truncDate(‘WK’,{event\_timestamp}),truncDate(‘WK’,now()),‘WK’)\>0,‘Last Three Weeks’,dateDiff(truncDate(‘WK’,{event\_timestamp}),truncDate(‘WK’,now()),‘WK’)=0,‘This Week’,NULL)

Then you can take the percent difference of the avgOversession and order it by is last three weeks.

percent difference= percentDifference(avgOverSession,[{is last three weeks} ASC],-1)

I’ve put it in a table here. For this table I filtered out any event that was not part of the last three weeks or this week.

![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/4/49989669d42e1a20a7363e28c587d63e812ba4d9.png)

If you want it in an insight you can make a top ranked calculation and display that number. I only took the number of results to be one and again filtered only to the last four weeks.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/b/b7868ca1e57a954c8900431bbd54b3cbdaca8714.png)

Here is what it would look like

![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/1/140b1a5383e549f3e930b1b2f5e1ce356fad8e2c.png)

Let me know if that works, or if I missed anything
