Forum Discussion
Cumulative Total
- 10 years ago
ElliotP Sorry about the original post. It was from my phone and had typos :smileywink:
Okay here is the formula for Running Total as a Calculated Column (prorerly formatted)
Running Total COLUMN = CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= EARLIER ( 'All Web Site Data (2)'[Date] ) )And as you can see it works! :smileyhappy:
And here's the MEASURE formula
Running Total MEASURE = CALCULATE ( SUM ( 'All Web Site Data (2)'[UniquePageviews] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ) )Which also works...
Thanks for the quick and explained reponse. I recieved the same thing; excep the Moving average values is the value for example for day 5 of 100, simply divided by 5 = 20. As opposed to being a running total divided by the number of days.
Something like
Day 1: 10
Day 2: 20
Day 3: 30
Day1avg: 10
Day2avg: 15
Day3avg: 20
I'll try and work it out, I'm trying to use the DATESBETWEEN function and some of the previousmonth and dateadd functions but I'm currently being told there are too few arguements (another issue).
I've taken your function and added in the calculated column for Cumulative Quantity (running total); but now it gives me 1717 as it seems I'm not filtering it by the day.
- ElliotP10 years agoPost Prodigy
I've solved thef irst part using the EARLIER function
Moving Average = DIVIDE ( CALCULATE ( SUM ( [Cumulative Quantity1] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= EARLIER ( 'All Web Site Data (2)'[Date] ) ) ), CALCULATE ( DISTINCTCOUNT ( 'All Web Site Data (2)'[Date] ), FILTER ( ALL ( 'All Web Site Data (2)' ), 'All Web Site Data (2)'[Date] <= EARLIER ( 'All Web Site Data (2)'[Date] ) ) ), 0 )So it produces a literal moving average.
Now its a matter of creating a Measure to show YOY, Month on Month and day on day. This might be easier to break it into a few colums and calculate that way or use a Time Intelligent Function.
- Sean10 years agoCommunity Champion
Okay great! Yes as you said - literal moving average because you didn't specify time period 7 Day, 1 Month, 6 weeks, 3 months...
For those you have to create the corresponding Running total first (which would again be your numerator)
say 3 months and then use something like this for the denominator
CALCULATE ( DISTINCTCOUNT(Calendar[Year-Month), DATESINPERIOD(CalendarTable[Date], LASTDATE(CalendarTable[Date]),-3,Month ) )
Yes I should have mentioned the Moving Average formula I posted was a Measure!
Here's the Column... :smileyhappy:
- ElliotP10 years agoPost Prodigy
I've created a Moving Average Measure and I'm now trying to create a column to produce a month on month moving average
MovingaverageMeasure = CALCULATE([Movingaveragemonthmeasure], DATESBETWEEN('All Web Site Data (2)'[Date], /*DATESBETWEEN function returns a table of days based on begin & end dates.*/ FIRSTDATE(PREVIOUSMONTH('All Web Site Data (2)'[Date])), /*PREVIOUSMONTH gets all the days from the previous month. FIRSTDATE returns the first day of that month.*/ LASTDATE(DATEADD('All Web Site Data (2)'[Date],-1,MONTH)) /*DATEADD allows us to navigate a number of periods back in time. LASTDATE gets the last date.*/ ) )It's currently returnng the same numbers as my 'Moving Average' Column
----------------
Disregard, I forgot to send this a bit ago.
- ElliotP10 years agoPost Prodigy
Ok, I'm attempting to calculate the Running Total Column; we've pulled and shaped the data again and redone some things; When i use the code:
Running Total Column = CALCULATE (DISTINCTCOUNT('All Web Site Data'[Date - Copy],DATESINPERIOD('All Web Site Data'[Date - Copy], LASTDATE('All Web Site Data'[Date - Copy]),-1,DAY )))I recieve the error "too many arguements were pased to DISTINTCOUNT function. The maximum argument count for the function is 1."
Then when I add a bracket and have this as my code;
Running Total Column = CALCULATE (DISTINCTCOUNT('All Web Site Data'[Date - Copy]), DATESINPERIOD('All Web Site Data'[Date - Copy], LASTDATE('All Web Site Data'[Date - Copy]),-1,DAY ))I recieve "A circular dependency was detected: All Web Site Data[Running Total Column], All Web Site Data[Month on Month Return], All Web Site Data[Running Total Column]."
It seems we need to isolate the running total column from the other two columns mentioned?
- ElliotP10 years agoPost Prodigy
The running total colomn is the same as my Cumulative Quantity1 column:
https://gyazo.com/ddbe9a3af55579df7d1f9cfc03daf008
Now let me try something here....
- ElliotP10 years agoPost Prodigy
I just tried:
Month on Month Total Sessions = Calculate(DISTINCTCOUNT('All Web Site Data'[Cumulative Quantity1]), DATESINPERIOD('All Web Site Data'[Date - Copy], LASTDATE('All Web Site Data'[Date - Copy]),-1, MONTH))And recieved a circular dependency bug.
Let me try using Sum instead of Distinctcount.
Returned Circular dependency. hmmmm
- ElliotP10 years agoPost Prodigy
I deleted the interferring column and created it as both a column and as a measure.
As a column it simply shows the same values as "Cumulative Quantity1" my already running total.
I tried adding the columns and the measures to graphs on my report page; yet when i add cumulative total it seems to mess up and shows tremendously high numbers in total on a bar graph, as in, it's high from the very beginning, as opposed to building and becoming bigger and bigger each month for example.
The same happens with my Moving average column.
I get the sense the graph issue may have something to do with the way the graph is interacting with the columns.
- ElliotP10 years agoPost Prodigy
I've created a measure;
Month on Month Total SessionsMeasuree = CALCULATE([Cumulative Quantity1M], DATESBETWEEN('All Web Site Data'[Date - Copy], /*DATESBETWEEN function returns a table of days based on begin & end dates.*/ FIRSTDATE(PREVIOUSMONTH('All Web Site Data'[Date - Copy])), /*PREVIOUSMONTH gets all the days from the previous month. FIRSTDATE returns the first day of that month.*/ LASTDATE(DATEADD('All Web Site Data'[Date - Copy],-1,MONTH)) /*DATEADD allows us to navigate a number of periods back in time. LASTDATE gets the last date.*/ ) )But this occurs: