Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bvandenbossche
Contributor
Contributor

cumulative sum with multiple conditions

Hi, 

I have a table with a list of invoices, with the invoice date, payment status, amount and if payment status = true also a payment date. Below is a small sample of the dataset:

Schermafbeelding 2019-11-03 om 19.07.59.png

Now I would like a table with one row per month, which gives for each month the cumulative amount invoiced and the unpaid balance. For the unpaid balance I want to take into account the invoices that are still unpaid today (payment status = false) as well as the invoices that were not yet paid at the end of the period in the current row (so payment date > last day of the month for this row). 

The cumulative amount works fine with: RangeSum(Above(Sum([Amount incl VAT]), 0, RowNo())). I'm struggling with the unpaid amount however, this doesn't seem to work: 

RangeSum(Above(Sum(
     {$<[Payment Status]={'False'}>+
     $<[Payment Date.Calendar.Date]={">$( monthend(max([Invoice Date.Calendar.Date])) )"}>}
     [Amount incl VAT]), 0, RowNo()
))
 
Schermafbeelding 2019-11-03 om 19.15.46.png

 

Any ideas on how to get this to work are highly appreciated! 🙂

Best regards,

Bart

6 Replies
Anil_Babu_Samineni

With in the object, Can you add [Payment Date.Calendar.Date] and [Payment Status] as dimension and see?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
bartvandenbossche
Contributor
Contributor

Hi, I'm not sure I understand your suggestion. If I add those 2 dimensions, I don't get a total per month anymore? Also, it has no effect on the outcome of my expression: 

 

Knipsel.JPG

 

 
sunny_talwar

May be you need this

RangeSum(Above(

  Sum({$<[Payment Status] = {'False'}, [Payment Date.Calendar.Date] = {">$(=MonthEnd(Max([Invoice Date.Calendar.Date])))"}>} [Amount incl VAT])

, 0, RowNo()))
bartvandenbossche
Contributor
Contributor

Hi, thanks for the suggestion, but that only returns 0's apparently...

Knipsel.JPG

sunny_talwar

Would you be able to share a sample to check this out?

bartvandenbossche
Contributor
Contributor

Sure, here is some sample data for 3 months.