),
IF(AND($D$6, $D$7),
),
)
),
IF($D$6,
),
IF($D$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
). To this formula logic and criteria’s in the same order: =LET(
jarir, D2,
extra, D3,
branded, D4,
unbranded, D5,
stmSelected, D6,
stmNotSelected, D7,
regionCriteria, B10,
regionCriterion, 'All POS'!F9:F375,
brandedCriteria, 'All POS'!K9:K375,
stmCriteria, 'All POS'!O9:O375,
FILTER(
'All POS'!C9:C375,
(regionCriterion = regionCriteria) *
((branded * (brandedCriteria = "Branded")) + (unbranded * (brandedCriteria = "Unbranded"))) *
((jarir * ('All POS'!I9:I375 = "Jarir")) + (extra * ('All POS'!I9:I375 = "Extra"))) *
IF(AND(stmSelected, stmNotSelected),
('All POS'!O9:O375 = 'All POS'!O6) + ('All POS'!O9:O375 = 'All POS'!O7),
IF(stmSelected,
(stmCriteria = "STM+"),
IF(stmNotSelected,
(stmCriteria <> "STM+"),
TRUE
)
)
)
)
To adapt your complex Excel formula logic to the specified criteria while maintaining the same order, it looks like you need to create a similar structure using the LET function and logic from your original formula. Here's how you can apply the criteria in a consistent manner while infusing your new requirements:
Transformed Formula
=LET(
jarir, $D$2,
extra, $D$3,
branded, $D$4,
unbranded, $D$5,
stmSelected, $D$6,
stmNotSelected, $D$7,
regionCriteria, $B$10,
regionCriterion, 'All POS'!F9:F375,
brandedCriteria, 'All POS'!K9:K375,
stmCriteria, 'All POS'!O9:O375,
FILTER(
'All POS'!C9:C375,
(regionCriterion = regionCriteria) *
((branded * (brandedCriteria = "Branded")) + (unbranded * (brandedCriteria = "Unbranded"))) *
((jarir * ('All POS'!I9:I375 = "Jarir")) + (extra * ('All POS'!I9:I375 = "Extra"))) *
IF(AND(stmSelected, stmNotSelected),
('All POS'!O9:O375 = 'All POS'!O6) + ('All POS'!O9:O375 = 'All POS'!O7),
IF(stmSelected,
(stmCriteria = "STM+"),
IF(stmNotSelected,
(stmCriteria <> "STM+"),
TRUE
)
)
)
)
)
Explanation of the Logic
-
Variables:
jarir, extra, branded, unbranded: These are boolean criteria that indicate selection for various categories.
stmSelected, stmNotSelected: These indicate whether certain criteria regarding STM are selected.
regionCriteria: This holds the value against which to filter regions.
- The criteria for filtering brand type (
brandedCriteria) and STM are defined and used in the filtering logic.
-
Filtering Logic:
- The
FILTER function retrieves data from the 'All POS'!C9:C375 range based on various combined conditions.
- The conditions are combined using multiplication (
*) and addition (+), which is essentially doing a logical AND and OR.
- It checks for the required regions, brand types, jars/extras, and the STM-related criteria.
-
STM Logical Checks:
- The checks for
stmSelected and stmNotSelected determine if the relevant STM conditions should apply.
- For ease of readability, this portion employs
IF statements nested to check different scenarios regarding STM selection.
Final Note
The adapted formula retains the structural logic of the original while incorporating the specified filters and criteria from your source. Make sure all your cell references and context align with your actual data. The FILTER function requires Excel 365 or Excel 2021 due to its dynamic array capability, so ensure you're using it in a compatible version.