make this formula shorter and more efficient while maintaining all criteria possibilities: =LET(
  jarir,         $D$2,
  extra,         $D$3,
  branded,       $D$4,
  unbranded,     $D$5,
  primaryLOB,    $C$12,
  primaryTier,   $C$13,
  primarySSub,   $C$14,
  primaryConfig, $C$15,
  primaryColor,  $C$16,
  sumCriteria, LAMBDA(hq,prog,
    IF(AND( NOT($D$6), NOT($D$7) ),

      SUMIFS(
        lastQ[W1],
        lastQ[[Measure]:[Measure]], $AB$9,
        lastQ[[LOB]:[LOB]], primaryLOB,
        lastQ[[Tier]:[Tier]], primaryTier,
        lastQ[[HQ]:[HQ]], hq,
        lastQ[[Sub]:[Sub]], primarySSub,
        lastQ[[Configuration]:[Configuration]], primaryConfig,
        lastQ[[Color]:[Color]], primaryColor,
        lastQ[[Programm]:[Programm]], prog
      ),
      IF(AND($D$6, $D$7),
        SUM(
          SUMIFS(
            lastQ[W1],
            lastQ[[Measure]:[Measure]], $AB$9,
            lastQ[[LOB]:[LOB]], primaryLOB,
            lastQ[[Tier]:[Tier]], primaryTier,
            lastQ[[HQ]:[HQ]], hq,
            lastQ[[Sub]:[Sub]], primarySSub,
            lastQ[[Configuration]:[Configuration]], primaryConfig,
            lastQ[[Color]:[Color]], primaryColor,
            lastQ[[Programm]:[Programm]], prog,
            lastQ[[STM+]:[STM+]], $C$6
          ),
          SUMIFS(
            lastQ[W1],
            lastQ[[Measure]:[Measure]], $AB$9,
            lastQ[[LOB]:[LOB]], primaryLOB,
            lastQ[[Tier]:[Tier]], primaryTier,
            lastQ[[HQ]:[HQ]], hq,
            lastQ[[Sub]:[Sub]], primarySSub,
            lastQ[[Configuration]:[Configuration]], primaryConfig,
            lastQ[[Color]:[Color]], primaryColor,
            lastQ[[Programm]:[Programm]], prog,
            lastQ[[STM+]:[STM+]], $C$7
          )
        ),
        IF($D$6,

          SUMIFS(
            lastQ[W1],
            lastQ[[Measure]:[Measure]], $AB$9,
            lastQ[[LOB]:[LOB]], primaryLOB,
            lastQ[[Tier]:[Tier]], primaryTier,
            lastQ[[HQ]:[HQ]], hq,
            lastQ[[Sub]:[Sub]], primarySSub,
            lastQ[[Configuration]:[Configuration]], primaryConfig,
            lastQ[[Color]:[Color]], primaryColor,
            lastQ[[Programm]:[Programm]], prog,
            lastQ[[STM+]:[STM+]], $C$6
          ),
          IF($D$7,

            SUMIFS(
              lastQ[W1],
              lastQ[[Measure]:[Measure]], $AB$9,
              lastQ[[LOB]:[LOB]], primaryLOB,
              lastQ[[Tier]:[Tier]], primaryTier,
              lastQ[[HQ]:[HQ]], hq,
              lastQ[[Sub]:[Sub]], primarySSub,
              lastQ[[Configuration]:[Configuration]], primaryConfig,
              lastQ[[Color]:[Color]], primaryColor,
              lastQ[[Programm]:[Programm]], prog,
              lastQ[[STM+]:[STM+]], $C$7
            ),
            0
          )
        )
      )
    )
  ),
  result,
    IF(AND(jarir, extra),
      SUM(
        IF(AND(branded, unbranded),
          sumCriteria("Jarir", "Branded") + sumCriteria("Jarir", "Unbranded"),
          sumCriteria("Jarir", IF(branded, "Branded", IF(unbranded, "Unbranded", "")))
        ),
        IF(AND(branded, unbranded),
          sumCriteria("extra", "Branded") + sumCriteria("extra", "Unbranded"),
          sumCriteria("extra", IF(branded, "Branded", IF(unbranded, "Unbranded", "")))
        )
      ),
      IF(jarir,
        IF(AND(branded, unbranded),
          sumCriteria("Jarir", "Branded") + sumCriteria("Jarir", "Unbranded"),
          sumCriteria("Jarir", IF(branded, "Branded", IF(unbranded, "Unbranded", "")))
        ),
        IF(extra,
          IF(AND(branded, unbranded),
            sumCriteria("extra", "Branded") + sumCriteria("extra", "Unbranded"),
            sumCriteria("extra", IF(branded, "Branded", IF(unbranded, "Unbranded", "")))
          ),
          ""
        )
      )
    ),
  result
)