• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

calculate number of days taken to pay

ayman galal

New Member
how many days taken to pay full value for each item?
 

Attachments

  • 1724529442777.png
    1724529442777.png
    9.5 KB · Views: 13
Last edited:
You would use running totals (accumulation) for both the sales and payments and look up the dates.
Code:
= LET(
    sale,      FILTER(sales, sales>0),
    salesDate, FILTER(date, sales>0),
    salesAcc,  SCAN(0, sale, SUM),
    pmntsAcc,  SCAN(0, payments, SUM),
    pmntDate,  XLOOKUP(salesAcc, pmntsAcc, date, "unpaid", 1),
    HSTACK(sale, pmntDate, pmntDate-salesDate)
  )
The resulting table is
1724578419359.png
If you want to show the payment days as part of the original table then output "" for lines without sales rather than filtering them out.

I have just added a Lambda function variant.
Code:
= PaymentDaysλ(sales, payments, date)
 

Attachments

  • HOW MANY DAYS.xlsx
    15.1 KB · Views: 11
Last edited:
Back
Top