Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
kroberts13
New Contributor III

Rolling Average per day of month

Hello,

I am trying to get a rolling average for each day of the month.

I have a total budget number for each month. I am trying to Get the average per day and make that a rolling number up through the end of the month. Does anyone have any idea on how to do so? Thank you in advance for your help and please let me know if any further information is needed.

Thank you

1 Solution

Accepted Solutions

Re: Rolling Average per day of month

Something along these lines

Table:

LOAD *,

  If(MonthYear = Previous(MonthYear), RangeSum(Peek('CumAmountPerDay'), AmountPerDay), AmountPerDay) as CumAmountPerDay;

LOAD *,

  Date(MonthYear + IterNo() - 1) as Date

While MonthYear + IterNo() - 1 <= MonthEnd(MonthYear);

LOAD Date(MonthStart(Date#(MonthYear, 'MMM-YYYY')), 'MMM-YYYY') as MonthYear,

  Amount,

  Amount/Day(MonthEnd(Date#(MonthYear, 'MMM-YYYY'))) as AmountPerDay;

LOAD * Inline [

MonthYear, Amount

Nov-2016, 64523214.21

Dec-2016, 96369197.32

];

Capture.PNG

12 Replies

Re: Rolling Average per day of month

May be look into: The As-Of Table

Re: Rolling Average per day of month

kroberts13
New Contributor III

Re: Rolling Average per day of month

Still no luck. It seems simple, I am just struggling with it. I have the monthly budget number and just need to average that out daily with a running sum

Re: Rolling Average per day of month

Would you be able to share a sample with expected output?

kroberts13
New Contributor III

Re: Rolling Average per day of month

Capture.PNGI have the total ($96369197.32) for each month in the format of mm/YYYY. That is what I am trying to average per day with the running sum to eventually show that total on the last day of every month.

Re: Rolling Average per day of month

So you want to divide 96369197.32 equal among each of the day within a month?

kroberts13
New Contributor III

Re: Rolling Average per day of month

Essentially, yes

Re: Rolling Average per day of month

Something along these lines

Table:

LOAD *,

  If(MonthYear = Previous(MonthYear), RangeSum(Peek('CumAmountPerDay'), AmountPerDay), AmountPerDay) as CumAmountPerDay;

LOAD *,

  Date(MonthYear + IterNo() - 1) as Date

While MonthYear + IterNo() - 1 <= MonthEnd(MonthYear);

LOAD Date(MonthStart(Date#(MonthYear, 'MMM-YYYY')), 'MMM-YYYY') as MonthYear,

  Amount,

  Amount/Day(MonthEnd(Date#(MonthYear, 'MMM-YYYY'))) as AmountPerDay;

LOAD * Inline [

MonthYear, Amount

Nov-2016, 64523214.21

Dec-2016, 96369197.32

];

Capture.PNG

kroberts13
New Contributor III

Re: Rolling Average per day of month

Perfect! This worked! I have one more small question, do you mind emailing me? kyle.roberts@osumc.edu

Thank you so much for your help!

Community Browser