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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

manipulating data in table

Hi everyone,

I have a simple table with 3 fields:

YearMonthPayment
20103500
20104500
20105500
20106500
20107500
20108500
20109500
201010500
201011500
201012500
20111500
20112500
20113500
20114500


What I'm trying to do in Qlik is get the total balance (7000) then reduce the balance by the monthly payment, so the table will end up looking like this:

YearMonthBalance
201036500
201046000
201055500
201065000
201074500
201084000
201093500
2010103000
2010112500
2010122000
201111500
201121000
20113500
201140


Though I'm fairly new to Qlik and am not sure of the best way to do this, if anyone can point me in the right direction it would be much appreciated.

Kind Regards,
Phil

4 Replies
spsrk_84
Creator III
Creator III

Hi Phil,

I think u might have used the expression like this i.e TOTAL BALANCE,instead of this u try with this

Sum(Payment).Try this one in cse if u find any problem u please attach the sample file then i can solve ur problem.

Rgds,

ajay

Not applicable
Author

Hi Ajay,

Many thanks for the reply.

I have 2 dimensions (year,month) and only one expression (payment) from this I'm trying to calculate the balance in Qlik.

I'm guessing I need to use set analysis or aggregation but am struggling at the moment... I can't even get a running sum for the payment at the moment 😞

Thanks,
Phil

Not applicable
Author

Hi Phil,

You can try the following. This will give you what you need at load time. I hope this is what you need.

pymt_tmp:
LOAD * INLINE [
PYear, PMonth, PPayment
2010, 3, 500
2010, 4, 500
2010, 5, 500
2010, 6, 500
2010, 7, 500
2010, 8, 500
2010, 9, 500
2010, 10, 500
2010, 11, 500
2010, 12, 500
2011, 1, 500
2011, 2, 500
2011, 3, 500
2011, 4, 500
];


A1:
load PYear as Year1, PMonth as Month1, PPayment as Payment1 , 1 as PK
resident pymt_tmp;

drop table pymt_tmp;

A2:
load PK, sum(Payment1) as TPayment2
resident A1
GROUP BY PK;

A3:
Left join (A1)
load TPayment2 as TPayment3
resident A2;

pymt:

load Year1 as Year3, Month1 as Month3, (TPayment3 - (Payment1 * rowno())) as Payment3
resident A1;

drop table A2

This will create two table, you can ignor table A1, the table Pymt is the one what you need.

Regards,

Mukund

Not applicable
Author

Hi Mukund,

Many thanks for the reply, the code you supplied is really helpful for something else I'm working on 🐵

For this though I need to keep the underlying data at the payment level and calculate the balance in the chart... as there's a lot of underlying data that builds up to the totals.

I found something on the Qlik help for chart inter record functions and used the following to create an expression called Payment:

if(rowno()=1,sum( {1} Total Payment ), above( Balance ) - Payment )


Kind Regards,
Phil