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

previous amount compared to current amount

Hi Guys,

I need a little help.

I'm trying to do the following.

I want to calculate the amount of the previous month and subtract that to the amount of the current month.

For example.

In january the amount was 31. Since there is no previous month, null is returend.

In februari the amount was 56. So if I would select february I would get 56 - 31 (month januari) = 45.

In march the amount was 93. So 93 - 56 (month february) = 37

I want to solve this in my script, but also want to see it how it's done in set analysis.

Please find an example of my script.

Thanks!

Sam

Edited: 03-05-2016:

Please have a look at the attached files.

9 Replies
sunny_talwar

Something like this?

Sum(Aggr(Above(Sum({<month>}beginSaldo)), month)) - Sum(beginSaldo)

Anonymous
Not applicable
Author

Thanks! I dont want to solve it in my chart. I want to solve it in my script.

sunny_talwar

Can you elaborate how you imagine to see these values?

Anonymous
Not applicable
Author

do you mean, how I want the end result to be?

For example.

In january the amount was 31. Since there is no previous month, null is returend.

In februari the amount was 56. So if I would select february I would get 56 - 31 (month januari) = 45.

In march the amount was 93. So 93 - 56 (month february) = 37

In other words if I select the current month, I get the amount of the current month and of the previous month.

Hope this clarifys

sunny_talwar

May be this?

Table:

LOAD *,

  MonthName(date) as MonthYear;

LOAD date,

    amount

FROM

amount.xlsx

(ooxml, embedded labels, table is page1);

AggrTable:

LOAD *,

  If(MonthYear = AddMonths(Peek('MonthYear'), 1), Total - Peek('Total'), Null()) as Diff;

LOAD MonthYear,

  Sum(amount) as Total

Resident Table

Group By MonthYear

Order By MonthYear;


Capture.PNG

Anonymous
Not applicable
Author

Hi,

I created a dataset, trying the same as you did above. But without succes.

I'm also trying to make a cumulative of all the transaction per customer.

I dont know where it goes wrong. Is it the expression or the 'Order By' statement?

Where can I upload files to the forum?

Regards,

Sam

sunny_talwar

Check this link: Uploading a Sample

Anonymous
Not applicable
Author

I've edited the original file.

Please have a look at the file.

I'm trying to accumulate all the transactions per customer.

And have a column that shows the difference. between the previous amount and the current amount.

if the debt has not being payed fully, then 'still in debt', else 'no more debt'.

Hope you can help me

cheers!

Sam

Anonymous
Not applicable
Author

Hi Sunny,

Where u able to look at the problem? I'm stuck and really need help .

Many thanks in advance!

Regards,

Sam