Numbers using braces in a formula? Syntactically, they seem to define collections inline in a formula.

How to use braces in a formula? Syntactically, they seem to define collections inline in a formula.


How to get same results shown in https://apple.stackexchange.com/questions/356355/macos-numbers-and-tricks-with-braces



Posted on Jun 28, 2022 12:43 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 28, 2022 8:28 AM

I think probably a more common term might be an "array" of values rather than a collection.


Here is a common use:




=XLOOKUP(A2,{1;2;3;4},{"one";"two";"three";"four"},"NF")


Or, if your region uses , as a decimal separator, then:


=XLOOKUP(A2;{1;2;3;4};{"one";"two";"three";"four"};"NF")


XLOOKUP looks at the value in cell A2, finds its position in the array of values between the first set of { } and then uses that position to look of the value in the second set of { }. This is more compact than putting the lookup values in ranges of cells.


SG

11 replies
Question marked as Top-ranking reply

Jun 28, 2022 8:28 AM in response to Sunnyintoronto123

I think probably a more common term might be an "array" of values rather than a collection.


Here is a common use:




=XLOOKUP(A2,{1;2;3;4},{"one";"two";"three";"four"},"NF")


Or, if your region uses , as a decimal separator, then:


=XLOOKUP(A2;{1;2;3;4};{"one";"two";"three";"four"};"NF")


XLOOKUP looks at the value in cell A2, finds its position in the array of values between the first set of { } and then uses that position to look of the value in the second set of { }. This is more compact than putting the lookup values in ranges of cells.


SG

Jul 4, 2022 8:11 PM in response to Sunnyintoronto123

Maybe this will work for you...

select cell B2, then type, or copy and paste from here the formula:

=REGEX.EXTRACT($A2,"(.+)\n(.+)\n(.+)",1, COLUMN()−1)


type the return key to enter the formula

select cell B2, copy

select cells B2 thru the end of column D (or as needed), paste


If you move to columns other than A with the source and B thru D then the formula will need to change to accommodate the column location. There are other ways to solve that, so post back if you have specific questions.

Wayne





Jun 30, 2022 5:23 AM in response to Sunnyintoronto123

In cell B10 try the following formula:

=IFERROR(REGEX.EXTRACT($A10,".+",COLUMN()−1),"")

Fill to the right to complete the row then fill down to complete the column


The " . " in the expression ".+" means "any character except new line". The "+" means keep extracting until you hit a new line character (or the end of the string).


Or you can hard code the numbers into the formula instead of using COLUMN

B10=IFERROR(REGEX.EXTRACT($A10,".+",1),"")

C10=IFERROR(REGEX.EXTRACT($A10,".+",2),"")

D10=IFERROR(REGEX.EXTRACT($A10,".+",3),"")

then fill down to complete the table

Jun 29, 2022 10:28 PM in response to Sunnyintoronto123

There are no cells "named Array" in a Numbers document.


There is a Numbers preference setting :

that permits using "names" in column and row "Header" cells in place of column letters and row numbers in formula cell references,


General preference stated by those answering questions in this community has been to NOT check this preference when taking screen shots to be placed in these discussions.


For trouble-shooting on a not familiar table, it is much quicker to locate cell K25 (which is always in the 25th row of the 11th column of the named table) than to find cell HaroldFortnight (which could be anywhere on the table, and require determining which column was labeled "Harold" and which row was labeled "Fortnight"



Jun 30, 2022 4:58 AM in response to SGIII

I am trying to group multiple inputs (indeterminate size) for a formula into single cell instead of a cell for every input; advantages include:

  1. a single header for a group of inputs.
  2. no need to add/delete row or cell when number of inputs change
  3. reformat font size for a cell instead of multiple cells


The following Excel example is very similar to what I am trying to do for Numbers;


I also wish there's something like Powershell split function

Split String using Regular Expression (Regex)
The following command splits the string which is in Distinguished Name format and returns only the name components.
1
2
	
$String = "OU=MTS,OU=CORP,DC=CONTOSO,DC=COM"
($String -split ',*..=' ) -ne ''

Jul 2, 2022 2:05 AM in response to Sunnyintoronto123

i finally found free Google App called Regex version 2.0.1 which educated me on Regex.


Following script is what i came up with to get text between curly braces delimited by commas; similar to Powershell split function of array format of indeterminate size { abc, def, etc }.


This one liner script frees me to

① have text o/s curly braces as comments.

② avoid needless steps for formatting multiple cells to accommodate each element of array

③ multiple cells of formulas


(?<=[{|,])\w+(?=[},])


Comments wellcome.


Hopefully Apple will add function called split()









This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Numbers using braces in a formula? Syntactically, they seem to define collections inline in a formula.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.