Formula to consolidate Data and remove entries with no data in that year

Newbie73

Board Regular
Joined
Feb 4, 2024
Messages
109
Office Version
  1. 365
Platform
  1. Windows
Hello,

I need help creating a formula that would consolidate results, as in keeping the same ID for a year a Sum the numbers for that year while also at the same time, if that ID hasn't had a value in that year, to be removed from the filter/list.

For example the data:

PT1000000 - 1 - 2012
PT1000000 - 1 - 2013
PT1000000 - 2 - 2014
PT2000000 - 3 - 2013
PT2000000 -1 - 2014
PT2000000 - 1 - 2015

Result in column 2013 then consolidating the data and sum the previous result:

P100000 - 2
PT20000 - 3

2014

P100000- 4
PT20000 - 4

2015 (PT10000 was removed from 2015 list as it doesn't have any result in this year, it it had an entry with the year with a number even if it's zero it would still count and be in 2015)

PT20000 - 5


Example spreadsheet with expected results and a few more entries:

test3.xlsx

Thank you in advance!
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
you could use
=UNIQUE(FILTER($A$1:$A$12,$D$1:$D$12=H$1))

to ge the PT numbers

I'm not sure what you are doing
is this a sum of the number grwate and = to the PT id
for example
2013
PT 1 = 3

not following that calculation , based on examples

test3(Sheet1).xlsx
ABCDEFGHIJKLMNOPQRSTUVWX
1PT10000012012201220132014201520162017
2PT10000012014PT1000001PT1000003PT1000004PT2000006PT2000007PT2000008
3PT10000022013PT2000002PT2000005PT3000002PT3000003
4PT20000032014
5PT200000120164
6PT20000012015
7PT20000022013
8PT20000012017
9PT30000012015
10PT30000012016
11PT30000012015
12PT20000002014
test3(Sheet1)
Cell Formulas
RangeFormula
H2,W2,T2:T3,Q2:Q3,N2:N3,K2:K3H2=UNIQUE(FILTER($A$1:$A$12,$D$1:$D$12=H$1))
I5I5=SUMIFS($B$1:$B$12,$D$1:$D$12,">="&H$1,$A$1:$A$12,H2)
 
Upvote 0
Hello etaf and thanks for your reply! In the calculations is a sum of column B from that same ID, from all the entries of that year or all the previous years (some times the same ID might also have several entries within the same year)

For example, 2013 L2 equals 3, because PT100000 "1" in 2012 (row 1) and row 3 PT100000 "2" in 2013 bringing the total of 3 for ID PT100000 in 2013

Another example, 2015 - R2 equals 6

B4, B6, B7 are entries from the same ID, PT200000 from 2015 and previous years, sum equals 6

Hope this helps, let me know if not and I can explain in a different way
 
Upvote 0
Hello, here is an option:

Excel Formula:
=LET(
ID,$B$2:$B$13,
count,$C$2:$C$13,
years,$E$2:$E$13,
year,I2,
a,UNIQUE(FILTER(ID,years=year)),
b,DROP(REDUCE("",a,LAMBDA(x,y,VSTACK(x,SUM(FILTER(count,(ID=y)*(years<=year)))))),1),
HSTACK(a,b))
 
Upvote 0
Solution
just for completeness of my version
=SUMIFS($B$2:$B$13,$D$2:$D$13,"<="&H$1,$A$2:$A$13,H2)
you could add add
=IF(W2="","",SUMIFS($B$2:$B$13,$D$2:$D$13,"<="&W$1,$A$2:$A$13,W2))

but the LET by

hagia_sofia

doing it all in one go is probably better, as you have 365 version

test3(Sheet1).xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1201220132014201520162017
2PT10000012012PT1000001PT1000003PT1000004PT2000006PT2000007PT2000008
3PT10000012014 PT2000002PT2000005PT3000002PT3000003 
4PT10000022013      
5PT20000032014      
6PT20000012016      
7PT20000012015      
8PT20000022013      
9PT20000012017      
10PT30000012015      
11PT30000012016      
12PT30000012015      
13PT20000002014      
14      
15      
16      
17
test3(Sheet1)
Cell Formulas
RangeFormula
H2,W2,T2:T3,Q2:Q3,N2:N3,K2:K3H2=UNIQUE(FILTER($A$2:$A$13,$D$2:$D$13=H$1))
I2:I16,X2:X16,U2:U16,R2:R16,O2:O16,L2:L16I2=IF(H2="","",SUMIFS($B$2:$B$13,$D$2:$D$13,"<="&H$1,$A$2:$A$13,H2))
 
Upvote 0
If I may asked one more thing, I'm using your formula Hagia_sofia as it does both things automatically. How would I change the formula to also do the exact same thing on Column C values? (it was empty on the example spreadsheet, added some numbers now as I forgot they were also needed)
 
Upvote 0
If I may asked one more thing, I'm using your formula Hagia_sofia as it does both things automatically. How would I change the formula to also do the exact same thing on Column C values? (it was empty on the example spreadsheet, added some numbers now as I forgot they were also needed)

So, the result would consist of 3 columns where the 3rd would contain the same calculation as the 2nd or something else?
 
Upvote 0
Exactly the same yes, I've just updated the example sheet if it helps, sorry about it!
 
Upvote 0
So, this?

Excel Formula:
=LET(
ID,$B$2:$B$13,
count_1,$C$2:$C$13,
count_2,$D$2:$D$13,
years,$E$2:$E$13,
year,I2,
a,UNIQUE(FILTER(ID,years=year)),
b,DROP(REDUCE("",a,LAMBDA(x,y,VSTACK(x,SUM(FILTER(count_1,(ID=y)*(years<=year)))))),1),
c,DROP(REDUCE("",a,LAMBDA(x,y,VSTACK(x,SUM(FILTER(count_2,(ID=y)*(years<=year)))))),1),
HSTACK(a,b,c))
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

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