Creating A Concatenated ID w/ Leading Zeroes Using Sequence in Google Sheets - arrays

I am very close here but due to my still novice understanding of Regular Expressions, I am not getting exactly the results I want.
In B1 sits a variable used to create a sequence.
The desired output is
Team01,Team02,Team03,Team04,Team05,Team06,Team07,Team08,Team09,Team10,Team11,Team12
The data in that table is generated by this formula in B3
=ARRAYFORMULA({"TeamID";"Team"&SEQUENCE(SUBSTITUTE(B1,"\\10\\2","^[1-9]\d*(?:\.\d{1,2})?$"))})
I know that the formula isn't working because the RegEx isn't correct and maybe i need to be using other tools, but I'm still new to this and trying to piece together what needs to change.

You can also try the even shorter and "easier to the eye"
=ARRAYFORMULA("Team"&TEXT(SEQUENCE(B1), "0#"))
or even
=INDEX("Team"&TEXT(SEQUENCE(B1), "0#"))

try:
=ARRAYFORMULA(TEXT(SEQUENCE(B1), "\T\e\a\m0#"))
or shorter:
=INDEX(TEXT(SEQUENCE(B1), "\T\e\a\m0#"))

Related

TEXTSPLIT combined with BYROW returns an unexpected result when using an array of strings as input

I am testing the following simple case:
=LET(input, {"a,b;c,d;" ; "e,d;f,g;"},
BYROW(input, LAMBDA(item, TEXTJOIN(";",,TEXTSPLIT(item,",",";", TRUE)))))
since the TEXTJOIN is the inverse operation of TEXTSPLIT, the output should be the same as input without the last ;, but it doesn't work like that.
If I try using a range instead it works:
It works for a single string:
=LET(input, "a,b;c,d;", TEXTJOIN(";",,TEXTSPLIT(input,",",";", TRUE)))
it returns: a,b;c,d
What I am doing wrong here? I think it might be a bug. Per TEXTSPLIT documentation there is no constraint of using TEXTSPLIT combined with BYROW when using an array of strings.
Not sure if this would classify as an answer but thought I'd share my attempt at it.
I don't think the problem here is TEXTSPLIT(). I tried different things. 1st I tried to incorporate FILTERXML() to do the split, with the exact same result. For good measure:
=BYROW({"a,b;c,d;","e,d;f,g;"},LAMBDA(item,TEXTJOIN(";",,FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(item,",",";"),";","</s><s>")&"</s></t>","//s"))))
Then I tried to enforce array usage with T(IF(1,TEXTSPLIT("a,b;c,d;",{",",";"},,1))) but Excel would not budge.
The above lead me to believe the problem is in fact BYROW() itself. Even though documentation says the 1st parameter takes an array, the working with other array-functions do seem to be buggy and you could report it as such.
For what it's worth for now; you could use REDUCE() as mentioned in the comments and in the linked answer however I'd preserve that for more intricate stacking of uneven distributed columns/rows. In your case MAP() will work and is simpler than BYROW():
=LET(input, {"a,b;c,d;";"e,d;f,g;"},
MAP(input, LAMBDA(item, TEXTJOIN(";",,TEXTSPLIT(item,",",";", TRUE)))))
And to be honest, this is kind of what MAP() is designed for anyway.

Getting the above value of the currently processed array (result array during formula execution in excel)

I know how to get a value from an above cell of a cell with a formula being executed but I am struggling to do the same with an array. You can simply refer to the above cell and then let the drag function of excel do the magic for the other consequence cells.
However, doing that with a dynamic array that has a single formula is new to me. I want to be able to get the above (calculated) value of a result array (currently being executed by a formula).
Take a look at the attached picture, you can see at C3 I failed to refer to the above row of the result array. The expected column in E2 is what the result should be.
I hope my question is clear...
Your help is highly appreciated
I don't think this particular case merits the use of a recursive set-up. Simply:
=LOOKUP(ROW(B3#),ROW(B3#)/(LEFT(B3#,4)="Ref:"),RIGHT(B3#,2))
In any case, for the recursion you'd require a LAMBDA, for example:
=LAMBDA(δ,IF(δ<1,"",IF(LEFT(INDEX($B$3#,δ),4)="Ref:",RIGHT(INDEX($B$3#,δ),2),MyLambda(δ-1))))
stored in Name Manager as MyLambda, after which you can enter in the worksheet:
=MyLambda(ROWS($1:1))
and copy down as required.
I'm certain this LAMBDA could be improved, even made to spill a dynamic array, though as I said, it's really not necessary here.

Checking for duplicates per column in a dynamic Excel array

I'm trying to generate a formula in Excel that evaluates the presence of duplicates in a dynamic array per column and then returns a new 1-dimensional array that contains either True or False when duplicates are present/absent. See the simplified example below.
Example array:
{a,b,c,d;
d,e,f,g;
a,h,i,j}
The output of the formula should result in {True,False,False,False}. What can I try next?
Seemingly simple, agreed, though until Microsoft release functions such as BYCOL it's anything but, assuming you're wanting to obtain your array output using a single formula.
One option would be:
=LET(ρ,A1:D3,κ,ROWS(ρ),ε,COLUMNS(ρ),η,SEQUENCE(κ*ε,,0),γ,MATCH(ρ,INDEX(ρ,1+MOD(η,κ),1+QUOTIENT(η,κ)),0)+SEQUENCE(,ε)/10^6,MMULT(SEQUENCE(,κ),N(INDEX(FREQUENCY(γ,γ)=0,SEQUENCE(κ,ε))))>0)
Replace A1:D3 as required.
Hopefully someone will come along with an improvement.
If you'd have BYCOL() you can use something like:
=BYCOL({a,b,c,d;d,e,f,g;a,h,i,j},LAMBDA(x,COUNTA(UNIQUE(x))<>ROWS(x)))
Not particularly dynamic as CHOOSE can't be set that way but if you have a smaller number of columns you can use the following:
=LET(data,E4:H6,CHOOSE(SEQUENCE(1,4),
IF(COUNTA(UNIQUE(INDEX(data,,1)))=ROWS(data),FALSE,TRUE),
IF(COUNTA(UNIQUE(INDEX(data,,2)))=ROWS(data),FALSE,TRUE),
IF(COUNTA(UNIQUE(INDEX(data,,3)))=ROWS(data),FALSE,TRUE),
IF(COUNTA(UNIQUE(INDEX(data,,4)))=ROWS(data),FALSE,TRUE))
)

Combine references to create new reference like ${var${randnum}}

I am trying to create a new reference containing another reference as in ${var${randnum}}.
Ultimately, I want to create a variable which refers to a two times two randomized set of variables.
As the above approach did not work, I developed it further with below result.
In the calculate field I write
concat('$','{','trust',${rand_no2},'_' ,${rand_no3_1},'}')
Which should result in
${trust1_1}
and respective combinations.
Without line 11 (name=ref2) the file compiles and I can start it in ODK Collect (v.2.4) on my phone. When I reach line 10 (in ODK Collect), however, I receive the message:
"Error Occured
Dependency cycle in s; recursion limit exceeded!!"
(I included line 11 to show what I want to do in the end.)
I am writing the file in Excel and compile it with ODK xlsform offline. (For testing I transfer it via cable to my phone.)
The xls file for reproduction can be found here:
https://forum.getodk.org/t/concatenate-references-to-create-new-reference-var-randnum/34968
Thank you very much in advance!
You're mixing up some things related to the ${q} syntax, question names and question values.
Note that ODK Collect does not actually understand the ${q} syntax (which is XLSForm-only). It's helpful to look at the actual form format that ODK collect understands which is called XForm, an XML format that XLSForm converts into. However, even if ODK Collect understood the ${q} syntax, your approach still wouldn't work since you're creating a string value for the ref question (using concat). This wouldn't magically be evaluated as a reference / formula. You cannot dynamically create a reference or formula.
At the moment (until ODK supports something like the local-name() function), maybe the best approach is to use position and put the calculated values inside a group. Something like //group/calc[number(${pos})] perhaps. Note that positions are 1-based (so the first item is position 1) and casting the position to a number or integer is required.

SPARQL: array-strings conversion / extraction

I am doing a SPARQL Query that for one variable gives me the output "[-1.6101874126499998e-19]". This is obviously a string containing an array (that could also contain more numbers). Is there a way to access the number in it or does it need to be done in the underlying graph?
If it needs to be changed in the graph, what is a good ontological way to create multi-dimensional arrays...?
xsd:float(SUBSTR(?var,2,STRLEN(?var)-2)) does the job in this case, but it's quite hacky :/

Resources