Trending Percentage over time - tableau-api

When I am trying to calculate a percentage over time with the rolling weighted denominator, what is that called? The calculation is basically
Users With WiFi Activity/Users
The line graph that I have is graphed daily on the x axis but at each day, it is only calculating the day of so the percentage is extremely lower, but what I want is on the line graph, on day, the percentage of WiFi users rolling 30 up to that day is this % vs only day x $.
Is that called a moving average?
Also, how is that calculate?
What Data should look like
Day Percentage SUMTotalWiFiUsersRolling SumTotalUsersRolling
8/1 85% 1800 2000
8/1 81% 1700 2100
What Tableau is doing
Day Percentage SUMTotalWiFiUsersDayOnly SumTotalUsersRolling
8/1 30% 600 2000
8/1 35% 735 2100

You're right, that is a moving average. MA since the day that you're fixing the 30 days period at is moving (each new day the window jumps by one day forward)
Is your data at the day level of detail? If so, this is the table calc you need:
WINDOW_AVG([SUMTotalUsersRolling],-29,0)
In the formula, we're starting at 29 days backwards from this day (0). So the 30 day average is including today
Formula format:
WINDOW_AVG(<field to average>,<number of periods to start from>,<period to end at>)

Related

why do SMA50 and SMA200 calculations differ on a 1Y price chart vs 2y price chart

We know that formula for Simple Moving Average (SMA) is the same, no matter what the length of observations period is. However, I don't understand why MA(50,C,MA,0) differs on a 1Y chart when compared to a 2Y chart for same security. For example, when you run this on S&P index as of 2/5/20 using Yahoo charts we get 2,998.20 as SMA50 for 2Y or 5Y observations, whereas the same is 3,217.60 for any period 1Y and under. Anyone knows why this differs ?
You need to look at what the tick interval is. The tick interval for 1Y is usually 1 day, but the tick interval will typically scale with the date range. The 2Y chart probably has a different tick interval, like 2 days (just a guess based on your observation). This means that the SMA50 would be calculated over 100 days worth of data, while the 1Y is calculated over 50 days worth of data.
In Yahoo charts, the 1Y chart is plotted using daily points, the 2Y chart is using weekly points. That means SMA50 for a 1Y chart is the 50 trading days average, while SMA50 for a 2Y chart is the 50 trading weeks average. That's why they are different.

Average Volume Every Weekday In a Month Tableau

I am trying to calculate an expression in Tableau 10.2 for a contact center use case.
I have calls at every hour all days of the week.
I need to calculate the average call per hour per day. For instance i need to calculate the average call every Sunday at 9 pm and use that in tool tip.
By this i am measuring how many average calls we get on a given Sunday or any other day of the week at a particular hour.
I had written an expression sadly that is not resulting in accurate number
AVG({ FIXED [Weekday Flagging],[Hour]:
AVG([Volume])})
Do suggest.
Very Recently I had a same requirement to see avg visitors on the hours of all the days of a week. My requirement was (Total No. Of Visitors on Sundays/No.Of Sundays) and then (Total No of Visitors #hour/No. Of Sundays).
1)create a calculated field : sum(volume)/countd(date) and name it 'Avg Volume'
2)drag date to 'Columns'. From the drop down click 'More' -> 'Weekday'
3)drag the calculated field to rows. This will give avg volume on each days of a week.
To get Avg Volume of hours
1)do the same procedure as above and instead of 'Weekday', drag Hour of the day to the column.
Link these 2 sheets using an action filter, so that if u click on sunday in the first sheet, it will show the avg volume of each hour of sunday in the second sheet.

Monthly average from daily data

I have a dataset of energy efficient smart AC units. Each one has an ID, and each unit has daily data that represents the cost saved (in dollars) for each day.
I want to create a bar graph that shows the average savings, per month, per unit. I'm really struggling, however. AVG([Elecsavingscost]) only gets me the average daily savings in a given month. SUM([Elecsavingscost]) * 30 gets me pretty close to what I want, but of course, not all months have 30 days.
Is there a more intelligent way to do this? I'm presuming it's possible...
It can be very easily done using R software. Following is the code to convert daily data to monthly data
install.packages(c("zoo","hydroTSM")
library(zoo)
library(hydroTSM)
data=read.csv("data.csv")
data #data should contain 2 or more columns; 1st column should be date in
#English (U.K.) format, 2nd and subsequent columns should be your daily data
date Elecsavingscost
01-01-1984 18.8
02-01-1984 20.2
03-01-1984 19
04-01-1984 19.6
05-01-1984 21.8
06-01-1984 21.5
.
.
.
25-12-2014 13.6
26-12-2014 13.6
27-12-2014 16.2
28-12-2014 18.2
29-12-2014 16.7
30-12-2014 19.4
31-12-2014 18.5
x1 <- zooreg(data$Elecsavingscost, start = as.Date("1984-01-01"))
## Daily to monthly conversion
Elecsavingscost_monthly<- daily2monthly(x1, FUN=sum, na.rm=TRUE)
write.csv(Elecsavingscost_monthly,"Elecsavingscost_monthly.csv")

Find and Rank Time Series MATLAB

I know there must be a simple way that I can learn to do this but I cannot imagine how to start. I am tasked with finding a top 10 matching daily wind power time series in a 30-day plus/minus window from the first day in the time series (Jan 1st) matching a single daily wind power time series and it is out of my level of experience in MATLAB. I have successfully done this matching a single time series of the current year with the exact calendar days from previous years, but I need a more robust searching method to find the best correlated time series in a +/- window of time. For example, I'm comparing a 120 day time series (without leap years) with 25 previous years during the same 120-day period (Jan-Apr). The end result will show me the top 10 time series with the years and Julian day or cumulative day listed and a correlation or RMSE value associated with it. My data looks like this arranged in a 365 (days) X 25 (years) array and I thank you very much for your help!
1182573 470528 1638232 2105034 1070466 478257 1096999
879997 715531 1111498 1004556 1894202 1372178 1707984
636173 937769 2119436 742710 1625931 1275567 1228515
967360 1103082 2218855 1643898 1822868 554769 1325642

Tableau - weekly average from daily data

Using Tableau 8.1.
Daily data like this:
Date Sales
1-1-14 $5
1-2-14 $2
...
6-15-14 $15
Which can be aggregated to weeks of course
Week 1 $15
Week 2 $12
Week 3 $10
Week 4 $13
etc.
I would like to get the weekly average of each month
So like this:
Weekly Average
Month 1 (weekly average of the weekly total sales) ($15+$12+$10+13)/4 = 12.5
Month 2
Month 3
Does that make sense? If ou simply put "average" in the tableau table, it gives the average daily value PER WEEK (or month) < - I don't want that. I want the average of the weekly totals per month.
Quite simple, actually.
Create these calculations
Unique Weeks = COUNTD(DATEPART('week',[Date]))
Weekly Average = sum([Sales])/[Unique Weeks]
Then simply report Weekly Average x Month (or Quarter or Year, etc.)
(Note: Some weeks have < 7 days).
This can be done very simply with one calculated field.
WINDOW_AVG(SUM([Sales]))
Then drag your Date pill onto the rows shelf twice, one aggregated to day, the other to week. Make sure pills are set to discrete (blue) and drag your Sales measure onto the shelf, also as discrete.