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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

add values of a column for the start of each month

Hi, how should the script be like if I want to add up the balance(refer below) for 1 Jan 14 and 1 Feb 14, 1 Feb 14 and 1 Mar 14, etc,...?

itemnumbalancemonth
231 Jan-14
2101 Feb-14
261 Mar-14
241 Apr-14
281 May-14

Thanks.

11 Replies
tresesco
MVP
MVP

It should be something like:

Load

          Sum(If (....

From <> Group By ....;

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Something like

T_Data:

LOAD intemnum,

  balance,

  Date(MonthStart(date#(month, 'd mmm-yyyy'))) As month

Inline

[

  intemnum, balance, month

  2, 3, 1 Jan-14

  2, 10, 1 Feb-14

  2, 6, 1 Mar-14

  2, 4, 1 Apr-14

  2, 8, 1 May-14

];

Data:

LOAD *,

  If(itemnum = Previous(itemnum), Alt(Previous(balance), 0), 0) + balance As cum2months

Resident T_Data;

DROP Table T_Data;

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Hi,

 


1:

load * inline
[
itemnum,balance,month
2,3,1-Jan-14
2,10,1-Feb-14
2,6,1-Mar-14
2,4,1-Apr-14
2,8,1-May-14
]
;
2:
load *,date(Date#(month,'DD-MMM-YY'),'M/D/YY') AS DATE
Resident 1;
DROP Table 1;

DROP Field month;

LOAD if(Previous(DATE)=AddMonths(DATE,-1),balance+Previous(balance),0) as new
Resident 2;

HTH.

Ravi N.

Not applicable
Author

if I were to use aggr function, how do I go about it?

Not applicable
Author

hey thanks! but if I were to use aggr function, how do I go about it?

Not applicable
Author

hey thanks! but if I were to use aggr function, how do I go about it?

tresesco
MVP
MVP

You mean, want this in the front -end. Aggr() might not be required. Create a sample qvw and share here explaining the expected output.

Not applicable
Author

Hi, this is the expected output:

itemnum

balancemonthavg balance
231 Jan-146.5
2101 Feb-148
261 Mar-145
241 Apr-146
281 May-14-

where 'avg balance'=sum(balance)/2 for 1 Jan-14 and 1 Feb-14, 1 Feb-14 and 1 Mar-14, etc,...

tresesco
MVP
MVP

If(rowno()<>NoOfRows(), RangeAvg(Sum(balance), Above(Sum(balance),-1)))

PFA