Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Average totals per month should sum(..) all previous dates until the requested monday's instead of only the month data

What we try to do is to get the average week supplies of a month (e.g. august), which are based on the totals of each monday of the month.

These totals are based upon the [ArticlePosts.Remaining number], If we want the totals of august we should count all totals of the remaining number (per articlecode and multiply by the fixed transfer pricing) until the monday.

See partial code below of the tables:


...
Articles:
LOAD ArticleCode,
[Article.Fixed transfer pricing]
...
FROM ...


ArticlesPosts:
LOAD BookingDate,
ArticleCode,
[ArticlePosts.Remaining number],
WeekStart(Date(Num(ArticlesPosts.BookingDate) + 6)) as BookingWeekMonday,
Date(MonthStart(WeekStart(Date(Num(ArticlesPosts.BookingDate) + 6))), 'MMM-YYYY') AS BookingMonthYearMonday,
Month(WeekStart(Date(Num(ArticlesPosts.BookingDate) + 6))) AS BookingMonthMonday,
applymap('Quarter', num(month(WeekStart(Date(Num(ArticlesPosts.BookingDate) + 6))))) AS BookingQuarterMonday,
Year(WeekStart(Date(Num(ArticlesPosts.BookingDate) + 6))) AS BookingYearMonday
...
FROM ...


PostsCalender:
LOAD
TempDate AS BookingDate,
Year(TempDate) AS BookingYear,
APPLYMAP('Quarter', NUM(Month(TempDate))) AS BookingQuarter,
Month(TempDate) AS BookingMonth,
Week(TempDate) AS BookingWeek,
WeekDay(TempDate) AS BookingWeekDay,
Day(TempDate) ASBookingDay,
Date(MonthStart(TempDate), 'MMM-YYYY') AS BookingMonthYear
RESIDENT
TempCalendar
ORDER BY
TempDate;
...


The problem is that if we select a BookingMonthYearMonday (the month lets say august) we only get the data of august, but in fact we would like to get the count until that particular date.

August has 5 mondays on which we would like to know the total amounts and we want to get the average of these amounts. The averages is not the problem, but the problem is getting to count the data of [ArticlePosts.Remaining number] until the WeekMonday.

A small sample of the data:

BookingsWeekMondayBookingsdateRemaining number
6/7/20096/7/20091
6/7/20093/7/200923
13-7-20097/7/20091
13-7-20098/7/20091
13-7-20099/7/20092
13-7-200910/7/20092
13-7-200913-07-200996
20-7-200914-07-20091
20-7-200915-07-20091
20-7-200920-07-200923
20-7-200916-07-200932
20-7-200917-07-2009161
27-7-200924-07-2009-4
27-7-200921-07-20093
27-7-200927-07-20095
27-7-200923-07-200951
27-7-200922-07-20097473
3/8/200930-07-20091
3/8/200931-07-20091
3/8/20091/8/20091
3/8/20093/8/200938
3/8/200928-07-200966
10/8/20097/8/20091
10/8/20098/8/20091
10/8/20096/8/20092
10/8/20095/8/20093
10/8/20094/8/200912
17-8-200911/8/20091
17-8-200914-08-20093
17-8-200913-08-20096
17-8-200912/8/20097
17-8-200917-08-200940
24-8-200920-08-20091
24-8-200921-08-20091
24-8-200918-08-20092
24-8-200919-08-20092
24-8-200924-08-200916
31-8-200926-08-20091
31-8-200925-08-20092
31-8-200927-08-20092
31-8-200931-08-20097
31-8-200928-08-2009116


The numbers which we need for august (based on the data sample above) should be:

3/8/20097979
10/8/20097991
17-8-20098031
24-8-20098053
31-8-20098181


These totals are all totals of the previous dates until the week date.
For these numbers we can calculate the averages of the month.

Has anyone got suggestions?

Thx already!

2 Replies
Not applicable
Author

Hi,

see the attached file for an idea.

Good luck!

Rainer

Anonymous
Not applicable
Author

The idea is clear, but I don't know how to get the total overview in one table instead of a total row in the table ...

We would like to have one overview of the correct totals (in fact we also have some averages over the weeks but for a start the totals are ok).

Don't know how to get it in one table ..