Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Adding credits and debits from same field

Anyone know how to add the credits and debits from the same field to end up with two different totals? The example is attached in excel format.

5 Replies
Not applicable
Author

Hi,

you can simply add an IF statement inside your Sum expression.

Credit:

sum(if([Actual Cost]<0,[Actual Cost],0))

Debit:

sum(if([Actual Cost]>0,[Actual Cost],0))

See attached example,

Ingo.

vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hi,

For financial calculation it is better to create Credit and Debit fields in Script:

You can use:

Load

ExpenseLine,

If(Amount>=,0,Amount,0) as Debit,

If(Amount<0,Amount,0) as Credit

From Table;

Now you can use

Sum(Debit) and Sum(Credit) in chart

hope this will help.

Regards

Vijay

jagan
Luminary Alumni
Luminary Alumni

Hi,

You can arrive a flag for Credit and Debit in script as suggested by Vijay

TableName:

Load

ExpenseLine,

If(Amount>=,0,Amount,0) as Debit,

If(Amount<0,Amount,0) as Credit

From Table;

Now you can use

Sum(Debit) and Sum(Credit) in chart

If you don't want to arrive a flag in script then use the following expressions

Credit:

=Sum({<[Actual Cost]={'<0'}>} [Actual Cost])

Debit:

=Sum({<[Actual Cost]={'<0'}>} [Actual Cost])

The best way to do this is arriving the flag for Debit and Credit in Script.

Hope this helps you.

Regards,

Jagan.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Try with this

TableName:

Load

ExpenseLine,

If(Amount>=,0,Amount) as Debit,

If(Amount<0,Amount) as Credit

From Datasource;

Now you can use

Sum(Debit) and Sum(Credit) in chart

This is the best one.

Celambarasan

Not applicable
Author

Thank you all for your suggestions, I was able to create what I need with your input! Venus