Named ranges with certain formulas don't return correct result

%3CLINGO-SUB%20id%3D%22lingo-sub-3067401%22%20slang%3D%22en-US%22%3ENamed%20ranges%20with%20formulas%20don't%20return%20correct%20result%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3067401%22%20slang%3D%22en-US%22%3E%3CP%3EI%20realized%20that%20named%20ranges%20defined%20by%20certain%20formulas%20don't%20return%20correct%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20instance%2C%20%60%3DIF(ROW(Sheet1!%24A%243%3A%24B%243)%26gt%3B0%2CINDEX(Sheet1!%24B%243%3A%24B%248%2C%7B3%2C4%7D))%60%20in%20a%20cell%20well%20returns%20an%20array%20%60%7B3%2C4%7D%60%20in%20my%20example.%20I%20define%20a%20named%20range%20%60f%60%20with%20the%20same%20formula%2C%20%60%3Df%60%20in%20a%20cell%20returns%20a%20single%20value%20%603%60.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20general%2C%20named%20ranges%20works%20fine%20with%20array%20formula.%20But%20there%20is%20still%20problem%20like%20this.%20I%20know%20that%20my%20problematic%20formula%20could%20be%20simplified%20(to%20%60INDEX(Sheet1!%24B%243%3A%24B%248%2C%7B3%2C4%7D)%60)%2C%20but%20I%20would%20like%20to%20know%20in%20general%20what%20prevents%20the%20named%20range%20from%20returning%20correct%20results.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20anyone%20advise%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202022-01-20%20at%2019.12.13.png%22%20style%3D%22width%3A%20572px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F341086i70335AD2A96779C0%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screenshot%202022-01-20%20at%2019.12.13.png%22%20alt%3D%22Screenshot%202022-01-20%20at%2019.12.13.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3067401%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3067539%22%20slang%3D%22en-US%22%3ERe%3A%20Named%20ranges%20with%20certain%20formulas%20don't%20return%20correct%20result%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3067539%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F113332%22%20target%3D%22_blank%22%3E%40Tie%20CHENG%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENaming%20the%20formula%20you%20actually%20use%20it%20as%20array%20formula%2C%20in%20Pre-DA%20Excel%20notation%20like%20formula%20to%20which%20CSE%20is%20applied.%3C%2FP%3E%0A%3CP%3EIn%20DA%20Excel%20CSE%20applied%20to%20array%20returns%20first%20element%20of%20the%20array.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20enter%20your%20formula%20with%20Ctrl%2BShift%2BEnter%2C%20i.e.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%7B%3DIF(ROW(Sheet1!%24A%243%3A%24B%243)%26gt%3B0%2CINDEX(Sheet1!%24B%243%3A%24B%248%2C%7B3%2C4%7D))%20%7D%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3Eit%20returns%20single%20value%203.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3071869%22%20slang%3D%22en-US%22%3ERe%3A%20Named%20ranges%20with%20certain%20formulas%20don't%20return%20correct%20result%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3071869%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F113332%22%20target%3D%22_blank%22%3E%40Tie%20CHENG%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20does%20seem%20odd.%26nbsp%3B%20I%20reduced%20the%20formula%20to%20the%20following%2C%20which%20gave%20a%20truncated%20array%20for%20'%3Df'%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3Ef%3A%0A%3DIF(TRUE%2Clist1)%0A%0Ag%3A%0A%3DIF(%7BTRUE%7D%2Clist1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BThen%20again%20'g'%20spilt%20the%20whole%20list.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9664%22%20target%3D%22_blank%22%3E%40JoeMcDaid%3C%2FA%3E%26nbsp%3BIs%20this%20how%20you%20intended%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I realized that named ranges defined by certain formulas don't return correct value.

 

For instance, `=IF(ROW(Sheet1!$A$3:$B$3)>0,INDEX(Sheet1!$B$3:$B$8,{3,4}))` in a cell well returns an array `{3,4}` in my example. I define a named range `f` with the same formula, `=f` in a cell returns a single value `3`.

 

In general, named ranges works fine with array formula. But there is still problem like this. I know that my problematic formula could be simplified (to `INDEX(Sheet1!$B$3:$B$8,{3,4})`), but I would like to know in general what prevents named ranges from returning correct results.

 

Could anyone advise?

 

Screenshot 2022-01-20 at 19.12.13.png

7 Replies

@Tie CHENG 

Naming the formula you actually use it as array formula, in Pre-DA Excel notation like formula to which CSE is applied.

In DA Excel CSE applied to array returns first element of the array.

 

You may enter your formula with Ctrl+Shift+Enter, i.e.

{=IF(ROW(Sheet1!$A$3:$B$3)>0,INDEX(Sheet1!$B$3:$B$8,{3,4})) }

it returns single value 3.

@Tie CHENG 

It does seem odd.  I reduced the formula to the following, which gave a truncated array for '=f'

f:
=IF(TRUE,list1)

g:
=IF({TRUE},list1)

 Then again 'g' spilt the whole list.

@JoeMcDaid Is this how you intended it?

@Sergei Baklan 

So do you believe this behaviour is just an odd leftover from pre dynamic array days or is it an intentional feature intended to provide backward compatibility?  In the attached file I have produced a similar example of an array that is truncated when output to the worksheet, yet will sum correctly in memory.  Very reminiscent of pre-DA days.

 

Oddly though, despite the fact that I was one of very few users that used named formulae on a regular basis to evade implicit intersection, I had not come across this particular issue.  Maybe it was that the logical part of the formula was most often itself an array.

@Peter Bartholomew 

Interesting finding. I don't know what is behind. That's not behavior for any named formula, perhaps with conditional functions only.

 

If use any of

=IF( 1, result )
=LET( v, result, v)
=+result

they all return spill. If now name above formulae, =newname returns spill for latest two, but single value for first one.

@Peter Bartholomew 

One more. If modify your formula as

result = IF( preTax? + {0}, amount, amount * (1 + rate))
it returns spill.
 
Same way as =IF( 1, SEQUENCE(5) ) returns single value, but =IF( {1}, SEQUENCE(5) ) - spill.
+ {0}
was a bit of a surprise.

@Peter Bartholomew Thanks for looping me in here. Engineering have completed an investigation, and this is a long-standing bug. It's difficult to see any scenarios where the current behavior would be preferred as it's effectively truncating the users array, so we plan to take up a fix. 

 

Being a calc fix, we'll roll this out very slowly to ensure there are no unforeseen issues.