'SUMIFS Between Conditions

I am looking for some help with a SUMIFS formula.

I am trying calculate the revenue between dates for a coupon code, where the coupon code sales are in a separate sheet. I need the between dates to be until that discount code appears in the sheet again.

For example, If a discount code is promoted on the 25th of January and again on the 30th of January, I need the 25th of January row to show the sales since then until the SAME code is promoted again (eg. between 25th January and between 30th January). The 30th of January row would then show the revenue from that date onwards, until the code appears again in another date row in the future.

This is my formula: =SUMIFS('Code Revenue Feed'!$E:$E,'Code Revenue Feed'!$C:$C,D2,'Code Revenue Feed'!$A:$A,">=" &$B2)

This formula does not show between dates, only from the date it is promoted but I need to show from that date, until the next date the code appears again.

Here's my dataset (please filter the code column by KATIEHAYES so you can see what I mean): https://docs.google.com/spreadsheets/d/1kzU6T6a95WPoCDkkMjDmqWkKTDOxA0whn1Zk5kGRbBQ/edit?usp=sharing



Solution 1:[1]

For this to work, you need to enter an end date in column C (in my copy of your data, this is in cell C664 of the Posting Details UK sheet) where I have chosen 31-Dec-2022 (as your file is view-only, and because you appear to have a filter active on the Posting Details UK sheet, when I copied your data the last row of data on my sheet is 663)

=SUMIFS('Code Revenue Feed'!$E$3:$E$5180,'Code Revenue Feed'!$C$3:$C$5180,D2,'Code Revenue Feed'!$A$3:$A$5180,">="&C2,'Code Revenue Feed'!$A$3:$A$5180,"<"&INDIRECT("C"&IFNA(match(D2,D3:D$663,0)+ROW(),664)))

the above formula can be entered in cell E2 of your UK sheet, and then copied down. This formula uses the INDIRECT() function to determine the 'until' date - if a match for the current coupon code cannot be found in the remaining rows, then the end date from row 664 is used (you will have to adjust both the 663 and 664 references as you have almost 200 more rows of data). Screenshot illustrating suggested formula

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Spectral Instance