Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculate Monthly Average

Hi Everyone -

I have a table which lists a date and number of transactions for the last 3 months.

I am trying to add a third column called "Average Count Per Month" to show the average # of transactions per month. I would like to list the average number per month for each line so that I can create a graph similar to the one below (done through Excel).

I've tried using aggr() and sum()/count() a few different ways but no luck so far. Any idea how this can be done?

Thanks in advance.

Michael

   

DateCountAverage Count Per Month
2015-03-1134.33
2015-03-1264.33
2015-03-1344.33
2015-04-0573.67
2015-04-0623.67
2015-04-0823.67
2015-05-1244.00
2015-05-1354.00
2015-05-1434.00
2015-06-0167.67
2015-06-0287.67
2015-06-0397.67

Excel_Graph.png

1 Solution

Accepted Solutions
tschullo
Creator III
Creator III

Script Sample:

 

DataTable:

LOAD * INLINE [
Date, Count, Month
2015-03-11, 3, Mar
2015-03-12, 6, Mar
2015-03-13, 4, Mar
2015-04-05, 7, Apr
2015-04-06, 2, Apr
2015-04-08, 2, Apr
2015-05-12, 4, May
2015-05-13, 5, May
2015-05-14, 3, MayCapture.JPG
2015-06-01, 6, Jun
2015-06-02, 8, Jun
2015-06-03, 9, Jun
]
;

MonthAverage:
Load
Month,
round(Avg(Count),0.01) as Average
Resident DataTable
Group by Month;

View solution in original post

5 Replies
Not applicable
Author

try to make a pivot and group by Dates and use Average function at count.

then do a chart on pivot

Hope It will solve.

Thanks

A

tschullo
Creator III
Creator III

You could add a month column, then add a table that contains the average for a given monthh that would be linked by month field. You could then graph that value in your line graph as well.

Table 1

DateCountMonth
2015-03-113Mar
2015-03-126Mar
2015-03-134Mar
2015-04-057Apr
2015-04-062Apr
2015-04-082Apr
2015-05-124May
2015-05-135May
2015-05-143May
2015-06-016Jun
2015-06-028Jun
2015-06-039Jun

Table 2

MonthAverage Count Per Month
Mar4.33
Apr3.67
May4.00
Jun7.67


tschullo
Creator III
Creator III

Script Sample:

 

DataTable:

LOAD * INLINE [
Date, Count, Month
2015-03-11, 3, Mar
2015-03-12, 6, Mar
2015-03-13, 4, Mar
2015-04-05, 7, Apr
2015-04-06, 2, Apr
2015-04-08, 2, Apr
2015-05-12, 4, May
2015-05-13, 5, May
2015-05-14, 3, MayCapture.JPG
2015-06-01, 6, Jun
2015-06-02, 8, Jun
2015-06-03, 9, Jun
]
;

MonthAverage:
Load
Month,
round(Avg(Count),0.01) as Average
Resident DataTable
Group by Month;

awhitfield
Partner - Champion
Partner - Champion

HI Michael,

see the attached example, looks pretty close:

Anonymous
Not applicable
Author

Thanks Tony. This did the trick.

Michael