0

I have a sheet that does auto-analysis of surveys, and I'd like to have it analyze subsets of the data based on another variable. I've got two separate tables: Table 1 is the variable I want to group the analysis by, and Table 2 has all the questions I want to analyze.

What I can't figure out is how to write syntax that will repeat the second table for each possible value of Table 1.

Input:

Table 1    Table 2:
Col1       ColAP  ColAQ
A          21     43   
B          4      45
C          5      47

Desired output

Col1  ColAP  ColAQ
A     21     43   
A     4      45
A     5      47
B     21     43   
B     4      45
B     5      47
C     21     43   
C     4      45
C     5      47

...

The code I use to get Table 2 array is as follows:

=SORT(
{
ARRAYFORMULA(
  UNIQUE(
    REGEXREPLACE(
     FILTER(
      {
       Highlights!$AP$4:$AP,
       ARRAYFORMULA(
        REGEXREPLACE(Highlights!$AQ$4:$AQ," Total$","")
       )
      , REGEXREPLACE(Highlights!$D$4:$D,"^[\S\s]*$","Index")
      }
    ,REGEXMATCH(Highlights!$D$4:$D,"^(.*)\:([Bb]efore|[Aa]fter).*")
    )
   ,"^(.*)\:([Bb]efore|[Aa]fter).*","$1")
  )
 )
;ARRAYFORMULA(UNIQUE(REGEXREPLACE(FILTER({Highlights!$AP$4:$AP,ARRAYFORMULA(REGEXREPLACE(Highlights!$AQ$4:$AQ," Total$","")),Highlights!$D$4:$D},REGEXMATCH(Highlights!$D$4:$D,"^(.*)\:([Bb]efore|[Aa]fter).*")),"^(.*)\:([Bb]efore|[Aa]fter).*","$1")))}
,2,True,1,True)

I tried using variations of =UNIQUE(Arrayformula({Col1},{Table2})), for every unique combination of values in Col1 and Table 2, but that didn't work because of unequal range lengths. or perhaps a query that would do that . . .

Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54
Josh
  • 311
  • 3
  • 11
  • share a copy of your sheet – player0 Feb 06 '20 at 21:14
  • I agree with player0 that this will be very do-able with a shared sheet from which to demonstrate the right formulas – MattKing Feb 06 '20 at 22:08
  • Sure, I'll share as soon as I have a chance to remove information that may be identifying. – Josh Feb 07 '20 at 23:33
  • Here's the sheet and range: https://docs.google.com/spreadsheets/d/1MA8feBrOWgU_swDpqZ_YbwBz6Dsvn-pELKROagg4tmA/edit#gid=856238229&range=A4:E1002 – Josh Feb 08 '20 at 00:04
  • What are you actulaly trying to do here? I think it's not possible without a super-long formula but it could be done much quicker and simpler with an Apps Script function bound to the sheet. – Rafa Guillermo Feb 10 '20 at 15:30
  • @Rafa, I'm trying to create a list of every variable that has a "before" and "after" tag in my sheet, grouped by their parent and grandparent tags, as well as indices for each parent or grandparent tag, and repeat that list, for every value in the grouping variable so that I can get means and paired T-tests, and n's with which to generate visualizations that help me explore the data before I write reports (keeping track of how many calculations I run and adjusting my alpha cut-off accordingly). I think my "Before" and "After sections above convey the step I'm stuck on. – Josh Feb 12 '20 at 00:32

0 Answers0