A ayman galal New Member Aug 24, 2024 #1 how many days taken to pay full value for each item? Attachments 1724529442777.png 9.5 KB · Views: 13 Last edited: Aug 24, 2024
A ayman galal New Member Aug 25, 2024 #3 kindly find the attached file Attachments HOW MANY DAYS.xlsx 9.2 KB · Views: 4
P Peter Bartholomew Well-Known Member Aug 25, 2024 #4 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 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: Aug 25, 2024
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 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)