4

I'm hoping to create a TOCOL in excel of an array of values based on variable criteria. Eg. When it meets one criteria, I wish for it to be able to return an array of values associated with that criteria (eg stores in that region), and when it meets another criteria return values associated to that criteria.

Sales Region Number of stores Criteria
www WA 3 FALSE
xxx WA 3 TRUE
yyy NSW 2 TRUE
zzz VIC 4 TRUE

There would be another table to lookup data which I wish to return (eg replenishment stock)

Tried playing around with SEQUENCE and TOCOL and I am reliably able to get a static value =IFERROR(TOCOL(CHOOSE(SEQUENCE(1,COUNTIF(\_sloc_repl\[Repl type\],XLOOKUP(TEXTAFTER(CELL("filename",$A$1),"\]"),\_tool\[Material type\],\_tool\[Repl type\])),1,0),FILTER(\_tool\[Criteria\],\_tool\[Criteria\]=TEXTAFTER(CELL("filename",$A$1),"\]"))),,0),"")

In this case I can get a result of

xxx
xxx
xxx
yyy
yyy
yyy
zzz
zzz
zzz

(which is a sequence based on the count of the first criteria found [3])

What I am hoping to achieve is

xxx
xxx
xxx
yyy
yyy
zzz
zzz
zzz
zzz

Which is a limited repeat of the value associated to the matching criteria

0

3 Answers 3

3

You may give a try to the following formula-

=TOCOL(TEXTSPLIT(TEXTJOIN("",1,REPT(FILTER(A2:A5,D2:D5=TRUE)&"|",FILTER(C2:C5,D2:D5=TRUE))),"|",,1),1)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

2

Another solution:

=TOCOL(IF(D2:D5,IF(SEQUENCE(1,MAX(C2:C5))>C2:C5,0/0,A2:A5),0/0),2)

enter image description here

Comments

1

Apply this formula for the table range

=DROP(TOCOL(TEXTSPLIT(TEXTJOIN("",TRUE,IF(D2:D5,REPT(A2:A5&"|",C2:C5),"")),"|")),-1)

or as @Harun24hr proposed:

=TOCOL(TEXTSPLIT(TEXTJOIN("",TRUE,IF(D2:D5,REPT(A2:A5&"|",C2:C5),"")),"|",,TRUE))

enter image description here

1 Comment

You can omit DROP() function by selecting ingore_empty parameter as true of TEXTSPLIT() function. =TOCOL(TEXTSPLIT(TEXTJOIN("",TRUE,IF(D2:D5,REPT(A2:A5&"|",C2:C5),"")),"|",,1)).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.