Forum Discussion
Tegzi
Jun 30, 2023Copper Contributor
Max function for Spilled Range
Hello,
I am struggling to resolve the following. With DA (Dynamic Array) formulas I calculate 3 columns:
App: =IF(D7=1,INDEX(SORTBY($AF$15#,$AG$15#,-1),SEQUENCE(AJ11)),INDEX(SORTBY($AF$15#,$AG$15#,1),SEQUENCE(AJ11)))
Actual Revenue: =XLOOKUP(AI15#,N15#,XLOOKUP(E6,O14:Q14,OFFSET(O15,,,COUNTA(N15#),3)))
Budget Revenue: =XLOOKUP($AI$15#,$N$15#,XLOOKUP($E$6,U14:W14,OFFSET(U15,,,COUNTA(N15#),3)))
These formulas work perfectly and they give me back spilled ranges, i.e. the length of the App/Actual Revenue/Budget Revenue keeps changing (depending on some user selection).
So, the calculations result in this table:
Now, here comes my problem. I have Label Position, which should give me back the MAX of the column B & C like this:
In other words:
C2 = Max(B2, C2)
C3 = Max(B3, C3)
...
CX = Max(BX, CX)
Like I said above, Column A, B & C contain DA formulas, that means that the length of columns keep changing. So the simple formulas like MAX(A:A,B:B) will not work. Maybe SEQUENCE and INDIRECT functions together somehow...not sure.
P.s.: don't get confused by the fact that in the above example it is always that B column is greater than C. Based on user selection there are times when it is opposite, or it is mixed (i.e. sometimes BX > CX, other times it is the other way around).
P.s.2: I use this table for creating a chart and the "Label Position" is required to calculate the Y position for some values I'd like to put on the chart 🙂 I am looking forward to a Dynamic Array function that spills similarly to the first 3 columns.
Thanks in advance for advices.
- Peter1979Copper Contributor
SergeiBaklan Do we have any idea why MAX doesn't spill? Do we know which functions spill and which don't?
If you mean to return max in each row in the array like
when MAX() has no idea you'd like to max by row or by col, by default it returns max for entire range. We need to instruct Excel additionally would we like to have max value in each row or in each column or by some more complex logic. For that BYROW, BYCOL or like functions exist.
- TegziCopper ContributorSergeiBaklan
Thanks. Indeed I did not even think that a simple if could handle the spilled range and DA function results...I guess I over complicated. Thanks for the solution.
Best regards,
TegziTegzi , you are welcome