Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ishan42d
Contributor
Contributor

Net balance calculation

I want to calculate net balance month on month using a column - DMBTR that lists all the debit and credit transactions. Another column,SHKZG which is an indicator tells us which line is a credit and which one is a debit. 

For ex: If SHKZG = 'S' then its a debit and if SHKZG = 'H' then its a credit. 

 

So using this I need to calculate the net difference between debit and credit transactions. I am using the below expression:

Sum(sum(if(SHKZG = 'H',DMBTR))-sum(if(SHKZG='S',DMBTR)))

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum(DMBTR * If(SHKZG  = 'H', 1, -1))

or this 

RangeSum(
  Sum({<SHKZG = {'H'}>}DMBTR),
 -Sum({<SHKZG = {'S'}>}DMBTR)
)

 

View solution in original post

3 Replies
sunny_talwar

Try this

Sum(DMBTR * If(SHKZG  = 'H', 1, -1))

or this 

RangeSum(
  Sum({<SHKZG = {'H'}>}DMBTR),
 -Sum({<SHKZG = {'S'}>}DMBTR)
)

 

ishan42d
Contributor
Contributor
Author

Thanks! the expression looks correct to me but somehow it is returning 0 balance on a month on month basis which ideally should not be the case. 

sunny_talwar

Would you be able to share a sample where we can see the issue?