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: 
Anonymous
Not applicable

Running Balance

Hi,

I have a question about counting running balance.

I have data like this:

          

TRX_TYPETRX_TYPE_NOLEDGER_IDLEDGER_NAMEGL_DATEGL_YEARDESCRIPTIONACCOUNT_NOACCOUNT_NAMEAMOUNT_DRAMOUNT_CROPENING_BALANCE
BALANCE12222LTD A2016BALANCE2555HUG50
PLB32222LTD A4/23/20162016A2555HUG10
PLB32222LTD A4/23/20162016B2555HUG20
PLB32222LTD A4/24/20162016C2555HUG30
PEMB22222LTD A4/28/20162016D2555HUG04
PEMB22222LTD A4/28/20162016E2555HUG05
PEMB22222LTD A4/25/20162016F2555HUG06

The sample data attached.

I want to count the balance for each row.

Example for the second row the result must be (OPENING_BALANCE+AMOUNT_DR-AMOUNT_CR) --> 50+1-0 =51

The third row must be --> 51+2-0 = 53

And so on. Here is the result i expected on my straight table.

GL_DATEDESCRIPTIONACCOUNT_NAMEAMOUNT_DBAMOUNT_CRBALANCE

-

BALANCEHUG0050
4/23/2016AHUG1051
4/23/2016BHUG2053
4/24/2016CHUG3056
4/28/2016DHUG0452
4/28/2016EHUG0547
4/25/2016FHUG0641

FYI i've try using this expression on my BALANCE column:

sum({<GL_YEAR={'$(vYear)'}>}TOTAL  SALDO) + RangeSum(Above(TOTAL sum(AMOUNT_DR-AMOUNT_CR), 0, NoOfRows(TOTAL)))

It works fine, but when i load all data (1000000 records) it runs very slow and can't load the table (keep loading)

Anybody can help me with this problem ?

Thanks in advance.

Really appreciate your help

4 Replies
sarvesh
Creator III
Creator III

Hi..Chou,

For this type of requirement you can use Pivot Table.

Please remember to mark this as "helpful" & "correct answer" if your query has been solved.

This will help users identify the answers should they come across this thread in the future.

Regard's

Sarvesh Srivastava

Anonymous
Not applicable
Author

Hi Sarvesh,

Can you give me the example please ?

Thanks in advance.

sarvesh
Creator III
Creator III

Please watch this video then you can understand how can make total of every column, click on below mentioned video.

QlikView | Pivot Tables - YouTube

Please remember to mark this as "helpful" & "correct answer" if your query has been solved.

This will help users identify the answers should they come across this thread in the future.


Regard's

Sarvesh Srivastava

michael123
Partner - Creator
Partner - Creator

Alternatively you  could calculate the balance in the load of the data with peek or previous function. Risk is that the load section takes too long instead though.

Here is an example but there are more here if you google,

Running Sum on Load Script

Regards,

/Michael

edit: Link wrong