felixstraube
Well-known Member
- Joined
- Nov 27, 2023
- Messages
- 897
- Office Version
- 365
- Platform
- Windows
- Web
I was working on a formula and I needed to get the value of the last item of an array to create a sequence from 1 to that value. Something like this:
but instead of getting an array of 15 numbers i got the "1" as you see in the example, which let me scratching my head at first.
It took me some time to realize that CHOOSEROWS actually returns an array of only one item, ({15}), instead of the value itself (15). And feeding that into SEQUENCE didn't work.
Then I used INDEX as a workaround like this:
This worked and I continued with my formula.
Now the question is: What is the best way, or best practice, to get the actual value from one item of an array? Is there a better way than using INDEX?
Book1 | ||||
---|---|---|---|---|
A | B | |||
1 | Array | No the result i wanted | ||
2 | 5 | 1 | ||
3 | 10 | |||
4 | 15 | |||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | B2 | =SEQUENCE(CHOOSEROWS(A2:A4, -1)) |
but instead of getting an array of 15 numbers i got the "1" as you see in the example, which let me scratching my head at first.
It took me some time to realize that CHOOSEROWS actually returns an array of only one item, ({15}), instead of the value itself (15). And feeding that into SEQUENCE didn't work.
Then I used INDEX as a workaround like this:
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Array | No the result i wanted | INDEX workaround | ||
2 | 5 | 1 | 1 | ||
3 | 10 | 2 | |||
4 | 15 | 3 | |||
5 | 4 | ||||
6 | 5 | ||||
7 | 6 | ||||
8 | 7 | ||||
9 | 8 | ||||
10 | 9 | ||||
11 | 10 | ||||
12 | 11 | ||||
13 | 12 | ||||
14 | 13 | ||||
15 | 14 | ||||
16 | 15 | ||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | B2 | =SEQUENCE(CHOOSEROWS(A2:A4, -1)) |
C2:C16 | C2 | =SEQUENCE(INDEX(CHOOSEROWS(A2:A4,-1), 1)) |
Dynamic array formulas. |
This worked and I continued with my formula.
Now the question is: What is the best way, or best practice, to get the actual value from one item of an array? Is there a better way than using INDEX?