1
votes

I was going through tableau tutorial and there I came across this Moving Average. I know that If I want to Calculate moving average I can do that from "Quick Calculation Table ( Where the default Moving average is for previous 2 days)".

Data Source

Sample Data Screenshot enter image description here

Below shown Image is the Quick Calculation of Moving Average for previous 3 Days.

enter image description here

Here is the sample data from the above shown figure:

enter image description here

So, If I want to Calculate previous 3 days moving average for 3rd Jan 2014 ( Including the current date), the calculation will be like:

(2955+4391+2481)/3= 3255 ,Which is the result I am also Getting in Tableau Screenshot Show below :

enter image description here

Now I am finding the moving average for 4th Jan 2014 ( Including the Current Date), the calculation will follow like :

(4391+2418+2815)/3= 3,208, But I am not getting the same Result in the Tableau as shown in the Screenshot below : enter image description here

Here as you can see that the Moving average is 3,145 and my calculated moving average is 3,208.

Why tableau results are not same as mine manually calculated result ?

Below the The Screenshot of my "Edit Calculation box " Tableau: enter image description here

1
What level of granularity is your data, sales per store per day, or just sales per day? - hello_friend
@hello_friend Well the Actual Data is Sales per store per day. But I think at the end the plotted data will be total of sales of every store for that specific day. - Viral Parmar
I suspect the previous 3 values your equation is fetching relate to each individual store and not the aggregated sales figure. Consider first aggregating your sales variable to the day level and then applying a secondary running average equation on top of this and then check the result. - hello_friend
@hello_friend I have edited my post with link to data source and sample data screenshot. As you can see in the Screenshot that sales data for 1st Jan 2014 with shope ID :NYFLO152 is 70.290 and the data for the first jan in the given table is 2955 - Viral Parmar

1 Answers

3
votes

It's because your Tableau moving average is looking at the past 3 values plus the current. Which is 4 values. You want to look at the past 2 values plus the current value.

Simple to fix - edit your table calc to look at the past 2 Previous Values, not the 3 how it's currently set.