Sum total unique overlapping days within multiple ranges, based on a condition

plshalp

New Member
Joined
Nov 8, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
In this table I have multiple flights of a campaign that may or may not run on overlapping dates. The date range of the flights are denoted in the AB (start) and AC columns (end).

The intent is to sum all days in the date ranges relative to a campaign, in a way that no date is duplicated, to get the total aggregated daily runtime of a campaign. This can then be used to calulate the pacing column by comparing what has actually happened to what should have happened assuming an even pace.

Currently the "pacing" in the AB column is incorrectly showing twice as much as it should be. This is because the campaign_duration column and days remaining_column are not de-duplicating the duplicate date ranges in a campaign. I also don't know how to account for periods such as 8/07/2022 - 10/07/2022 which run in parallel to the longer flight above it, creating another layer of duplication inaccuracy when calculating the total deduplicated days across all period in a campaign.

The formula in question is in column W which basically sums the product of all start and dates of a flight relating to a campaign:

Excel Formula:
=IF(ISNUMBER(SEARCH("Using Campaign budget",I2)),SUMPRODUCT(($AD$2:$AD$10000-$AC$2:$AC$10000)*($T$2:$T$10000=T2)),N2-(M2-1))

If I add in UNIQUE():

Excel Formula:
=SUMPRODUCT(UNIQUE(AD2:AD9-AC2:AC9))

It seems to de-duplicate the duplicate date ranges but as soon as I add the campaign conditional to the end of the SUMPRODUCT formula:

Excel Formula:
*($T$2:$T$10000=T2)),N2-(M2-1))

I get #N/A in all cells.

All of this really starts to slow down once I add in a few thousand lines as well, can anyone help provide a better solution, or at least a way to deduplicate the repeating ranges with this method?

close.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Account nameCampaign nameAd Set or Insertion OrderReachImpressionsFrequencyCurrencyAmount spentAd set budgetAd set budget typeCampaign budgetCampaign budget typeStartsEndsReporting startsReporting endsprog_leadadvertisercampaignad_set_or_ioplatformcampaign_durationdays_passeddays_remainingexpected_budget_spentactual_budget_spentpacingline_startline_endmodified_line_end
2Test AccountCampaign ATargeting A26175712007534.58728133NZD9440Using campaign budgetLifetime15000Lifetime14/07/202230/10/20221/01/20226/11/2022BobTest AccountCampaign ATargeting AFacebook34623611010231.2138720951.24205%14/07/202230/10/202230/10/2022
3Test AccountCampaign ATargeting B25344639222.52217487NZD568.16Using campaign budgetLifetime15000Lifetime31/10/202231/12/20221/01/20226/11/2022BobTest AccountCampaign ATargeting BFacebook34623611010231.2138720951.24205%31/10/202231/12/20226/11/2022
4Test AccountCampaign ATargeting C32945462201.4029443NZD241.92Using campaign budgetLifetime15000Lifetime11/07/202213/07/20221/01/20226/11/2022BobTest AccountCampaign ATargeting CFacebook34623611010231.2138720951.24205%11/07/202213/07/202213/07/2022
5Test AccountCampaign ATargeting D17533261681.49249986NZD225.54Using campaign budgetLifetime15000Lifetime8/07/202210/07/20221/01/20226/11/2022BobTest AccountCampaign ATargeting DFacebook34623611010231.2138720951.24205%8/07/202210/07/202210/07/2022
6Test AccountCampaign ATargeting E26175712007534.58728133NZD9440Using campaign budgetLifetime15000Lifetime14/07/202230/10/20221/01/20226/11/2022BobTest AccountCampaign ATargeting EFacebook34623611010231.2138720951.24205%14/07/202230/10/202230/10/2022
7Test AccountCampaign ATargeting F25344639222.52217487NZD568.16Using campaign budgetLifetime15000Lifetime31/10/202231/12/20221/01/20226/11/2022BobTest AccountCampaign ATargeting FFacebook34623611010231.2138720951.24205%31/10/202231/12/20226/11/2022
8Test AccountCampaign ATargeting G32945462201.4029443NZD241.92Using campaign budgetLifetime15000Lifetime11/07/202213/07/20221/01/20226/11/2022BobTest AccountCampaign ATargeting GFacebook34623611010231.2138720951.24205%11/07/202213/07/202213/07/2022
9Test AccountCampaign ATargeting H17533261681.49249986NZD225.54Using campaign budgetLifetime15000Lifetime8/07/202210/07/20221/01/20226/11/2022BobTest AccountCampaign ATargeting HFacebook34623611010231.2138720951.24205%8/07/202210/07/202210/07/2022
Sheet1
Cell Formulas
RangeFormula
S2:U9S2=A2
W2W2=IF(ISNUMBER(SEARCH("Using Campaign budget",I2)),SUMPRODUCT(($AD$2:$AD$10000-$AC$2:$AC$10000)*($T$2:$T$10000=T2)),N2-(M2-1))
X2:X9X2=W2-Y2
Y2Y2=SUMPRODUCT(($AD$2:$AD$10000-$AE$2:$AE$10000)*($T$2:$T$10000=T2))
Z2:Z9Z2=(IF(ISNUMBER(SEARCH("using ad set budget",K2)),I2,K2)/W2)*X2
AA2:AA9AA2=IF(ISNUMBER(SEARCH("Using ad set budget",K2)),H2,SUMIFS(H:H,I:I,"*Using campaign budget",B:B,B2))
AB2:AB9AB2=AA2/Z2
W3:W9W3=IF(ISNUMBER(SEARCH("Using Campaign budget",I3)),SUMPRODUCT(($AD$2:$AD$1048576-$AC$2:$AC$1048576)*($T$2:$T$1048576=T3)),N3-(M3-1))
Y3:Y9Y3=SUMPRODUCT(($AD$2:$AD$1048576-$AE$2:$AE$1048576)*($T$2:$T$1048576=T3))
AE2:AE9AE2=IF(P2>AD2,AD2,P2)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top