Search code examples
google-sheetsgoogle-sheets-formula

How do I revise the existing Index query to add cell value from other sheets?


How do I add Module # column to the existing Index query?

The Index queries (Index!W2) and (Index!AJ2) are designed to display the cumulative assessment scores from sheets: (Module 1 - Module 4). The query result displays the following:

Index!W2 (Cumulative list from Modules 1-4, values:'No' or '0' or '1')

  • Standard
  • Learner
  • Grade

Index!AJ2 (Cumulative list from Modules 1-4, values: 'Yes' or '2)

  • Standard
  • Learner
  • Grade

The goal is to have the query result returned in sheets: Administrative View and Grade Level Dashboard

Example Admin View result

The 'Module #' is located in sheets (Module 1 - 4), in cell 'A2'. Each Module sheet is a cumulative list of assessment results (grouped by Module). How do I add this column in the Index sheet queries?

See Dummy Spreadsheet

Thanks for any assistance.


Solution

  • Added formula here for you to test out:

    =reduce(tocol(,1),tocol(A2:A,1),lambda(a,c,vstack(a,let(Σ,index(match(,0/(indirect(c&"!A:A")<>""))),
     rep_,indirect(c&"!A8"):index(indirect(c&"!A:A"),Σ), grp_,hstack(indirect(c&"!C8"):index(indirect(c&"!AF:AF"),Σ),indirect(c&"!AH8"):index(indirect(c&"!BK:BK"),Σ)), header_,hstack(indirect(c&"!C4:AF4"),indirect(c&"!AH4:BK4")), header_2,hstack(indirect(c&"!C5:AF5"),indirect(c&"!AH5:BK5")), module,indirect(c&"!A2"), size_,2,
     Λ,reduce(tocol(,1),sequence(columns(grp_)/size_,1,1,size_),lambda(a,c,vstack(a,hstack(wrapcols(index(header_,c),rows(rep_),index(header_,c)),rep_,choosecols(grp_,sequence(size_,1,c)),wrapcols(index(header_2,c),rows(rep_),index(header_2,c)),wrapcols(module,rows(rep_),module))))), 
     filter(Λ,regexmatch(index(Λ,,3)&"","No|1|0")+regexmatch(index(Λ,,4)&"","No|1|0"))))))
    

    enter image description here