Forum Discussion
Quarterly revenue formula help needed
Surely this is not your usual style! ![]()
This is taken directly from the djclements formula but refactored to give the result as a dynamic array.
=LET(
qtr, {1, 2, 3, 4},
closeDate, IF(
DATE(calendarYear, 1 + 3 * qtr, 0) < End,
DATE(calendarYear, 1 + 3 * qtr, 0),
End
),
openDate, IF(
DATE(calendarYear, 1 + 3 * (qtr - 1), 1) > Start,
DATE(calendarYear, 1 + 3 * (qtr - 1), 1),
Start
),
partQtr, (closeDate - openDate + 1) / (End - Start + 1),
percent, MAP(partQtr, LAMBDA(x, MAX(x, 0))),
revenue, percent * totalRevenue,
HSTACK(percent, revenue)
)There are slight differences in the results, but I think that is due to the difference in calculating month ends (otherwise it may be me fouling up).
PeterBartholomew1 Nice adaptation 🙂 I didn't notice any differences in the results (=MyRange=YourArray returned all TRUE's), so it looks like everything checks out.
I'm not too sure I have a "usual" style, lol. It can vary from one scenario to the next. I do so enjoy the challenge of writing complex, single-cell dynamic array formulas, but also appreciate the simplicity of old-school formulas, which when applied to an Excel table are dynamic enough in their own right. Going full-blown dynamic array right off the bat can sometimes fly right over the heads of your intended audience. 😉
Cheers!
- PeterBartholomew1Feb 27, 2024Silver Contributor
I guess lloydantonio gets the deciding vote on which version is preferred.
I tend to write the solutions I like, if nothing else to demonstrate that the approach based upon defined names and dynamic arrays is widely applicable. With you on the thread, I was sure of an audience of one and I can always apologise to the OP if it comes to that
.