google-sheetsgoogle-sheets-formula

Replace Indirect in a Countifs formula in Google Sheet


I'm trying to figure out a way to replace all these indirect into this formula:

={
"𝒇x"; 
MAP($A9:$A; LAMBDA(x; IF(AND(x <> ""; index(AL:AL; ROW(x)) <> "");
    IFERROR(
        (COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "P"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "D"; $DY$6:$6; $AL$6; $DY$5:$5; "H")) / 
        (COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "P"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "D"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "I"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "E"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(indirect("DY"&ROW(x)&":"&ROW(x)); "A"; $DY$6:$6; $AL$6; $DY$5:$5; "H"))
    ; "-")
; "")))}

I used the following formula until now but it stops working as soon as I modify the cell or even when I just copy/clear then paste back the same formula into the same cell (it seems that index(DY:; ROW(x)) : index (DY:;ROW(x)) is no longer supported or recognized as part of a formula).

={
"𝒇x"; 
MAP($A9:$A; LAMBDA(x; IF(AND(x <> ""; index(AL:AL; ROW(x)) <> "");
    IFERROR(
        (COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "P"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "D"; $DY$6:$6; $AL$6; $DY$5:$5; "H")) / 
        (COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "P"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "D"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "I"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "E"; $DY$6:$6; $AL$6; $DY$5:$5; "H") + 
         COUNTIFS(index(DY:; ROW(x)) : index(DY:;ROW(x)); "A"; $DY$6:$6; $AL$6; $DY$5:$5; "H"))
    ; "-")
; "")))}

I need to replace indirect because my spreadsheet has a lot of them and it slows down the sheet (or even prevents certain parts of my sheet from working). Is there a way to replace indirect or just to make the system recognize the code again?


Solution

  • You may try this in place of indirect:

    offset(index(DY:DY;row(x));;;;columns(1:1))
    

    Alternative:

    =vstack("𝒇x", 
        map(A5:A,lambda(x,if(and(x<>"",index(C:C,row(x))<>""),index(iferror(
            countifs(xmatch(index(D:D,row(x)):index(ZZZ:ZZZ,row(x)),{"P","D"})^0, 1, D2:2, C2, D1:1, "H") / 
            countifs(xmatch(index(D:D,row(x)):index(ZZZ:ZZZ,row(x)),{"P","D","I","E","A"})^0, 1, D2:2, C2, D1:1, "H") 
        , "-")),))))
    

    enter image description here