The error message "You've entered too few arguments for this function" typically arises when a function, such as SUMIFS, doesn't have the required number of parameters.
In the case of introducing a conditional region criterion based on whether D8 is TRUE, we need to ensure that all the necessary parameters in the SUMIFS functions are properly accounted for.
To conditionally add a criterion while ensuring that all required arguments are present, we can't directly manipulate the parameter lists. Instead, we can adjust the SUMIFS calls by including an auxiliary argument that resolves to an empty array or a relevant comparison based on the condition.
Here’s an updated version of your formula. We will use a more structured approach to include the region criteria and handle the arguments correctly:
=LET(
jarir, $D$2,
extra, $D$3,
branded, $D$4,
unbranded, $D$5,
primaryLOB, $C$13,
primaryTier, $C$14,
primarySSub, $C$15,
primaryConfig, $C$16,
primaryColor, $C$17,
regionMatch, IF($D$8, C8, ""), // Add reference to region here
sumCriteria, LAMBDA(hq, prog,
IF(AND(NOT($D$6), NOT($D$7)),
SUMIFS(
lastQ[W1],
lastQ[[Measure]:[Measure]], $AB$10,
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($D$8, lastQ[[region]:[region]], "") // Include region criterion
),
IF(AND($D$6, $D$7),
SUM(
SUMIFS(
lastQ[W1],
lastQ[[Measure]:[Measure]], $AB$10,
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$8, lastQ[[region]:[region]], "")
),
SUMIFS(
lastQ[W1],
lastQ[[Measure]:[Measure]], $AB$10,
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$8, lastQ[[region]:[region]], "")
)
),
IF($D$6,
SUMIFS(
lastQ[W1],
lastQ[[Measure]:[Measure]], $AB$10,
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$8, lastQ[[region]:[region]], "")
),
IF($D$7,
SUMIFS(
lastQ[W1],
lastQ[[Measure]:[Measure]], $AB$10,
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$8, lastQ[[region]:[region]], "")
),
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
)
Key Adjustments:
-
Region Match Criterion: The formula introduces IF($D$8, lastQ[[region]:[region]], "") as a method to add optional criteria conditionally, allowing for customization in the SUMIFS calls.
-
Consistent Use of Parameters: Ensure that every SUMIFS function has all its parameters and that conditionally included parameters do not create any omissions in required arguments.
Final Note:
Remember to check that the ranges you are passing (like lastQ[[region]:[region]]) match correctly in size and type with the criteria you are comparing them against (like C8). The expected output should work seamlessly without throwing errors. If you still face issues, please confirm the structure of your Excel data to ensure it aligns with the formula expectations.