Forum Discussion
Excel 365 SUM dynamic array at row level
Hi
(no LAMDBA here). I've been struggling with this for a moment, searched here & there for something similar to no avail.
In the below pic. Dummy arr is the representation of an array that doesn't exist on a sheet, it's calculated in a LET expression and in reality can involve more columns and rows
Question: is there a way to i.e. SUM that array row by row and get the below Expected arr (not on a sheet)?
Thanks
(I posted the question yesterday at a time where the site had issues. Can't find that post today...)
21 Replies
- PeterBartholomew1Silver Contributor
Since you now have Lambda functions, the solution simplifies. First, assuming the dummy array has been given a name
= BYROW(Dummy_arr, Sumλ) where Sumλ = LAMBDA(x,SUM(x))
or including the array definition within a LET
= LET( dummyArr, {1;10;100}*SEQUENCE(1,3), BYROW(dummyArr, Sumλ) )
I have attached a file, but it contains little by way of additional information.
- LorenzoSilver Contributor
I appreciate your follow up on this issue. Since I have the 1st wave of LAMBDAs I figured that one out but this can help others so thanks for sharing it
- PeterBartholomew1Silver ContributorI wasn't trying to patronise! I saw the old discussion on your profile page and though that bringing it up to date might help someone in future if they search the topic.
- PeterBartholomew1Silver Contributor
Some neat tricks, which address one of the weaknesses of dynamic arrays which still cause developers to revert to the flawed concepts of copying formulas with relative references!
In normal use, array formulas largely replace the need for helper ranges, so reducing the risk of error. In the attached, I have taken a different strategy and allowed the array formulas to write to dynamic ranges to a hidden helper sheet so that the xxxIFS family of functions may be used.
p.s. Lorenzo Matrix equations are not that scary! Because of the nature of my former employment, I have probably written more matrix equations than I have English language paragraphs!
where 'mask' is defined to by
= IF(dummyArr#,k)
- SergeiBaklanDiamond Contributor
PeterBartholomew1 , helper in grid is very often real helper, don't know why people try to avoid it and overcomplicate formulas. I like your solution.
- lori_mIron Contributor
Perhaps for an array of max values:
=LET( i,SEQUENCE(ROWS(array)), m,COLUMNS(array), arrayRank,i+PERCENTRANK.EXC(array,array,15), rowRank,SMALL(arrayRank,i*m), rowTot,MMULT(array*(arrayRank=rowRank),1^i), rowFreq,MMULT(N(arrayRank=rowRank),1^i), rowTot/rowFreq )
Change i*m to (i-1)*m+1 for array of min values
In the given example:
array ={1,2,3;10,20,30;100,200,300}
arrayRank ={1.1,1.2,1.3;2.4,2.5,2.6;3.7,3.8,3.9}
rowRank ={1.3;2.6;3.9}
rowTot ={3;30;300}The result is divided by the number of occurences of the max value if there is more than one.
- Detlef_LewinSilver Contributor
- LorenzoSilver Contributor
Thanks much. Classic, classic, for you :))
I'm more used to do a SIGN(SEQUENCE(COLUMNS(A2:C4))) but got it now and did what I actually needed to do as well (Average)
However, I don't see how a MIN or MAX would be doable. Surely you have another classic :)) trick for this, don't you?
- SergeiBaklanDiamond Contributor
If for the range in grid
=SUBTOTAL({5,4},OFFSET(INDEX(A2:C4,1,1),SEQUENCE(ROWS(A2:C4),,0),,,COLUMNS(A2:C4)))