Tableau running average - average

I have a column of numeric data and another column by date. I'm trying to calculate a running average by week. I'm using a table calculation, Running Total on Average. This is not producing the running average I am expecting.
Example:
For 3rd week Running average, the running average is calculating the first week average + second week average + third week average, and then taking the average of those 3 numbers. What I want it to do is take all prior 3 week data and THEN take one single average as a whole. Hope that makes sense.

This seems to have done it. Calculated field:
RUNNING_SUM(SUM([NPS]))/RUNNING_SUM(COUNT([NPS]))

Related

Want to SUM all values for a specific date within column NOT sum all values in that column

I want to create a graph which shows the total capacity for each week relative to remaining availability across a series of specific dates. Just now when I attempt this in Power Bi it calculates this correctly for one of the values (remaining availability) but generates a value much higher than expected by manual calculation for the total capacity - instead showing the total for the entire column rather than for each specific date.
Why is Power Bi doing this and how can I solve it?
So far, I have tried generating the graph like this:
(https://i.stack.imgur.com/GV3vk.png)
and as you can see the capacity values are incredibly high they should be 25 days.
The total availability values are correct (ranging from 0 to 5.5 days).
When I create matrices to see the sum breakdown they are correct but it only appears to be that when combined together one of the values changes to the value for the whole column.
If anyone could help me with this issue that would be great! Thanks!

Why are my values multiplying when I apply Month/Year to my values?

When I apply Month/Year to Cases or Deaths from my data, the values explode. For Cases it goes from approximately 48 million to over 1 billion, and for Deaths it goes from about 700 thousand to over 22 million. However, when I try the same thing with Initial Claims or the Stringency Index, my values remain correct. I'm trying to find the month over month percentage change by the way. And I'm using the Date column. I only select 2020 and 2021 in the filter for Year.
What I'm asking about is Sheet 21.
Link to workbook: https://public.tableau.com/app/profile/nilajah.rivers/viz/CoronaVirusProject_16323687296770/Sheet21
Your problem is that the data points are daily cumulative deaths. If you change the date aggregation to anything other than days, Tableau will default to summing the numbers for all the days in the month. This will give the wrong result, obviously.
If you want to show the correct total deaths or cases regardless of the time aggregation (months, days, weeks etc.) then you could use the New Case or New Death numbers plus a running sum table calculation. This will always give the correct total for the time period.
Table calculations will also allow automatic calculation of the period to period % change from the same data fields.
This is a common problem when working with datasets that offer pre-calculated aggregations. Tableau doesn't need that as it can dynamically calculate the aggregation of a field over any given time period but it is easy to forget which field has pre-aggregated data and which has raw data. Pre-aggregated fields assume a particular time period and can't be used for different time periods without disentangling that assumption (which is unnecessary if you also have the raw data (in this case daily new deaths/cases).

DAX Calculate Monthly Average

I am trying to create a measure to calculate a monthly average from a set of data that was collected every 15 minutes. I am newer to DAX and am just unsure how to intelligently filter by month without hard setting in the month ID #. The formula I am trying is:
Average Monthly Use:=AVERAGEX(VALUES('Lincoln Data'[Month]),[kWh])
Where kWh is a measure of the total usage in a column
Thanks in advance
DVDV
To get the monthly average usage, You need to sum up the total usage per user and divide by the total number of months for that user.
Without knowing what your tables look like, it's hard to give a very good formula, but your measure might look something like this:
= DIVIDE(SUMX(DataTable, [kWh]), DISTINCTCOUNT(DataTable[Year-Month]))

Matlab average number of customers during a single day

I'm having problems creating a graph of the average number of people inside a 24h shopping complex. I have two columns of data on a spreadsheet of the times a customer comes in (intime) and when he leaves (outtime). The data spans a couple of years and is in datetime format (dd-mm-yyyy hh:mm:ss).
I want to make a graph of the data with time of day as x-axis, and average number of people as y-axis. So the graph would display the average number of people inside during the day.
Problems arise because the place is open 24h and the timespan of data is years. Also customer intime & outtime might be on different days.
Example:
intime 2.1.2017 21:50
outtime 3.1.2017 8:31
Any idea how to display the data easily using Matlab?
Been on this for multiple hours without any progress...
Seems like you need to decide what defines a customer being in the shop during the day, is 1 min enough? is there a minimum time length under which you don't want to count it as a visit?
In the former case you shouldn't be concerned with the hours at all, and just count it as 1 entry if the entry and exit are in the same day or as 2 different entries if not.
It's been a couple of years since I coded actively in matlab and I don't have a handy IDE but if you add the code you got so far, I can fix it for you.
I think you need to start by just plotting the raw count of people in the complex at the given times. Once that is visualized it may help you determine how you want to define "average people per day" and how to go about calculating it. Does that mean average at a given time or total "ins" per day? Ex. 100 people enter the complex in a day ... but on average there are only 5 in the complex at a given time. Which stat is more important? Maybe you want both.
Here is an example of how to get the raw plot of # of people at any given time. I simulated your in & out time with random numbers.
inTime = cumsum(rand(100,1)); %They show up randomly
outTime = inTime + rand(100,1) + 0.25; % Stay for 0.25 to 1.25 hrs
inCount = ones(size(inTime)); %Add one for each entry
outCount = ones(size(outTime))*-1; %Subtract one for each exit.
allTime = [inTime; outTime]; %Stick them together.
allCount = [inCount; outCount];
[allTime, idx] = sort(allTime);%Sort the timestamps
allCount = allCount(idx); %Sort counts by the timestamps
allCount = cumsum(allCount); %total at any given time.
plot(allTime,allCount);%total at any given time.
Note that the x-values are not uniformly spaced.
IF you decide are more interested in total customers per day then you could just find the intTimes with in a given time range (each day) & probably just ignore the outTimes all together.

Trying to Average number of accounts by hour, day of week, and month

I'm in healthcare and we're trying to assess the number of discharges we have per hour of day, but we'd also like to be able to filter them down by day of week, or specific month, or even a particular day of week in a particular month (e.g. " what is the average number of discharges per hour on Mondays in January?")
I'm confident that Tableau can do this, but haven't been able to make the averages show up in my line graph... every time that I convert it from COUNT to AVG, the line simply goes straight. I got close when I did a table calculation to find the Average (dividing the count per hour by the number of days captured in the report), but when I add a filter for either the month or day of week, selecting one of the options of the filter reduces the total number that is being counted, rather than re-averaging the non-filtered items. (i.e. if the average of the 7 days of the week is "10" for a particular hour, and I deselect the first three days of the week, it's now saying that my average for that hour is roughly 6, despite the fact that all of the days are very close to 10 at that hour.)
Currently, my data table has the following columns:
Account#/MonthYear/HourOfDay/DayOfWeek
ex.12345678/ Jan-17 / 12 /Sunday
I would just create a few calculated fields to differentiate the parts of the calendar you might want to filter/aggregate on. Mixing the month and day of the week with filtering is pretty straight forward with the calculated fields. Then do standard summing to get what you are looking for because an average count of records is always one unless you are throwing some other calculation into the mix. I threw a quick example up on Tableau Public for you to get the idea.