SOLVED

Excel Challenge 4

%3CLINGO-SUB%20id%3D%22lingo-sub-1538018%22%20slang%3D%22en-US%22%3EExcel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538018%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3EI%20have%20problem%20in%20applying%20formula%20in%20Excel%20as%20following%3A%3CBR%20%2F%3EI%20Have%20some%20items%20with%20specific%20purchase%20code%20for%20each%20purchase%20times%2C%20also%20I%20have%20purchase%20Quantity%20and%20selling%20quantity%2C%20I%20need%20Stock%20quantity%20for%20each%20items%20per%20year%20in%20our%20warehouse%2C%3CBR%20%2F%3EFro%20example%20for%20item%20A%20we%20have%20purchase%20200%20PC%20in%202013%20and%20sold%20100%20PC%20in%20this%20year%20so%20in%20the%20end%20of%20year%20we%20have%20100%20PC%20in%20our%20stock%2C%3CBR%20%2F%3EIN%202014%20we%20have%20bought%20another%20250%20PC%20so%20we%20had%20350%20PC%20in%20stock%20%2C%20and%20sold%20190%20PC%20n%20this%20year%2C%20so%20we%20had%2060%20PC%20in%20our%20stock%2C%3CBR%20%2F%3ESo%20I%20need%20stock%20fir%20each%20item%20in%20end%20of%20years%3A%3CBR%20%2F%3EI%20attached%20the%20excel%20file%20which%20do%20it%20manually%20for%20stock%20and%20repeated%20in%20its%20columns%3A%3CBR%20%2F%3E%3CBR%20%2F%3EI%20appreciate%20for%20your%20help%20in%20advance%2C%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1538018%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538060%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538060%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244734%22%20target%3D%22_blank%22%3E%40Jalal_1988%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20clarify%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20931px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207089i6C6F3986644810D9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Efor%20first%20row%20you%20sell%2010%2C%20purchase%20200%2C%20how%20100%20appears%20in%20last%20columns%3F%3C%2FP%3E%0A%3CP%3Ein%20next%20row%20you%20sell%2020%20(total%2010%2B20%3D30)%2C%20purchase%20another%20200%20(total%20200%2B200%3D400)%20and%20still%20have%20100%20in%20the%20last%20column.%3C%2FP%3E%0A%3CP%3EOr%20that's%20only%20one%20purchase%20per%20each%20year%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538157%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538157%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EDear%20Sergei%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EFor%20each%20Cod%20the%20Purchase%20quantity%20is%20repeated%20%2C%20For%20each%20code%20only%20we%20purchase%20one%20time%2C%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3Esincerely%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538364%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538364%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244734%22%20target%3D%22_blank%22%3E%40Jalal_1988%3C%2FA%3E%26nbsp%3B%20%26nbsp%3BI%20think%20I%20see%20what%20you%20want%20even%20though%20I%20still%20don't%20understand%20why%20you%20do%20it%20that%20way.%26nbsp%3B%20But%20even%20so%20I%20don't%20understand%20why%20the%20total%20at%20the%20end%20of%202014%20is%2060%20instead%20of%200%20since%20you%20show%202%20buys%20of%2050%20each.%26nbsp%3B%20In%20any%20case%20try%20this%20formula%3A%3C%2FP%3E%3CP%3E%3D%5Bpurchase%20amt%5D%20-%20SUMIF(%20%5Byear%20column%5D%2C%20%22%26lt%3B%3D%22%20%26amp%3B%20%5Byear%20cell%5D%2C%20%5Bpurchase%20column%5D)%3C%2FP%3E%3CP%3Eso%20if%20your%20sample%20table%20is%20in%20the%20upper%20left%20corner%20then%20the%20formula%20in%26nbsp%3B%20G2%20would%20look%20like%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DD2%20-%20SUMIF(F%3AF%2C%22%26lt%3B%3D%22%26amp%3BF2%2CC%3AC)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538558%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538558%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244734%22%20target%3D%22_blank%22%3E%40Jalal_1988%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EStill%20can't%20understand%20the%20logic.%20Let%20take%20code%20102%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20648px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207143iC60B441F224C8BA2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20calculate%20Item%20A%20and%20Item%20B%20separately%20for%20this%20code%20or%20together.%20If%20separately%2C%20Item%20A%20purchased%20200%20in%202013%2C%20sold%20100%20in%202013%20(rest%20is%20100%2C%20as%20is%20in%20the%20sample)%20and%20another%20100%20in%202014.%20Thus%20it%20shall%20be%20zero%20on%20the%20end%20of%202014%20since%20there%20were%20no%20purchases%20of%20this%20code.%3C%2FP%3E%0A%3CP%3EIf%20calculate%20items%20together%20also%20not%20clear%20what%20is%20behind%20the%20numbers%20in%20last%20column.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538728%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538728%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EDear%20Sergei%3CBR%20%2F%3EWe%20need%20Stock%20in%20en%20of%20each%20Selling%20year%2C%20(forget%20purchase%20year)%2C%3CBR%20%2F%3E1-%20Purchase%20Q%20is%20repeated%20for%20each%20code%2C%26nbsp%3B%3CBR%20%2F%3E2-%20For%20item%20A%2C%20we%20Purchase%20200%20PC%20in%202013%20and%20sold%20100%20PC%20in%202013%20so%20end%20of%20selling%20year%202013%20we%20have%20100%20PC%20as%20stock%2C%26nbsp%3B%3CBR%20%2F%3E3-%20For%20item%20A%20in%202014%20we%20Purchase%20another%20250%20Pc%20so%20we%20have%20350%20PC%2C%20and%20sum%20of%20sold%20Q%20is%20190%20Pc%20so%20we%20have%2060%20Pc%20in%20end%20of%20selling%26nbsp%3B%20year%202014%20in%20stock%3CBR%20%2F%3Efor%20other%20items%20is%20like%20A%3CBR%20%2F%3E(just%20consider%20Selling%20year%20for%20Stock)%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538755%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538755%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244734%22%20target%3D%22_blank%22%3E%40Jalal_1988%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you.%20So%2C%20we%20don't%20care%20about%20the%20codes%2C%20we%20only%20calculate%20items%2C%20correct%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538839%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Challenge%204%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538839%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244734%22%20target%3D%22_blank%22%3E%40Jalal_1988%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'd%20add%20helper%20column%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20442px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207175i9D03BD03E4B97A9F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E(here%20is%20K)%20to%20indicate%20one-time%20purchase%20for%20each%20item%20in%20each%20year.%20Formula%20is%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D--(COUNTIFS(%24G%244%3A%24G4%2CG4%2C%24D%244%3AD4%2CD4)%3D1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEnd%20of%20the%20year%20balance%20could%20be%20calculated%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMIFS(%24F%244%3A%24F%2423%2C%24D%244%3A%24D%2423%2CD4%2C%24G%244%3A%24G%2423%2C%22%26lt%3B%3D%22%26amp%3BH4%2C%24K%244%3A%24K%2423%2C1)-%0ASUMIFS(%24E%244%3A%24E%2423%2C%24D%244%3A%24D%2423%2CD4%2C%24H%244%3A%24H%2423%2C%22%26lt%3B%3D%22%26amp%3BH4)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20you%20previous%20post%3C%2FP%3E%0A%3CP%3E%3CEM%3E3-%20For%20item%20A%20in%202014%20we%20Purchase%20another%20250%20Pc%20%3CSTRONG%3Eso%20we%20have%20350%20PC%2C%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Esum%20of%20sold%20Q%20is%20190%3C%2FSTRONG%3E%20Pc%20so%20%3CSTRONG%3Ewe%20have%2060%20Pc%3C%2FSTRONG%3E%20in%20end%20of%20selling%26nbsp%3B%20year%202014%20in%20stock%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActually%20350-190%20is%20equal%20to%20160%2C%20not%2060%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi All

I have problem in applying formula in Excel as following:
I Have some items with specific purchase code for each purchase times, also I have purchase Quantity and selling quantity, I need Stock quantity for each items per year in our warehouse,
Fro example for item A we have purchase 200 PC in 2013 and sold 100 PC in this year so in the end of year we have 100 PC in our stock,
IN 2014 we have bought another 250 PC so we had 350 PC in stock , and sold 190 PC n this year, so we had 60 PC in our stock,
So I need stock fir each item in end of years:
I attached the excel file which do it manually for stock and repeated in its columns:

I appreciate for your help in advance, 

7 Replies

@Jalal_1988 

Could you please clarify

image.png

for first row you sell 10, purchase 200, how 100 appears in last columns?

in next row you sell 20 (total 10+20=30), purchase another 200 (total 200+200=400) and still have 100 in the last column.

Or that's only one purchase per each year?

@Sergei Baklan 
Dear Sergei 
 
For each Cod the Purchase quantity is repeated , For each code only we purchase one time, 

sincerely 

@Jalal_1988   I think I see what you want even though I still don't understand why you do it that way.  But even so I don't understand why the total at the end of 2014 is 60 instead of 0 since you show 2 buys of 50 each.  In any case try this formula:

=[purchase amt] - SUMIF( [year column], "<=" & [year cell], [purchase column])

so if your sample table is in the upper left corner then the formula in  G2 would look like:

 

 

 

EDIT: I retract the previous formula because although I think it is inline with what you want, I didn't see the whole sheet and all the inconsistencies that are in it as @Sergei Baklan mentioned just a few.  

 

@Jalal_1988 

Still can't understand the logic. Let take code 102

image.png

We calculate Item A and Item B separately for this code or together. If separately, Item A purchased 200 in 2013, sold 100 in 2013 (rest is 100, as is in the sample) and another 100 in 2014. Thus it shall be zero on the end of 2014 since there were no purchases of this code.

If calculate items together also not clear what is behind the numbers in last column.

@Sergei Baklan 
Dear Sergei
We need Stock in en of each Selling year, (forget purchase year),
1- Purchase Q is repeated for each code, 
2- For item A, we Purchase 200 PC in 2013 and sold 100 PC in 2013 so end of selling year 2013 we have 100 PC as stock, 
3- For item A in 2014 we Purchase another 250 Pc so we have 350 PC, and sum of sold Q is 190 Pc so we have 60 Pc in end of selling  year 2014 in stock
for other items is like A
(just consider Selling year for Stock)  

@Jalal_1988 

Thank you. So, we don't care about the codes, we only calculate items, correct?

best response confirmed by Jalal_1988 (Contributor)
Solution

@Jalal_1988 

I'd add helper column

image.png

(here is K) to indicate one-time purchase for each item in each year. Formula is

=--(COUNTIFS($G$4:$G4,G4,$D$4:D4,D4)=1)

End of the year balance could be calculated as

=SUMIFS($F$4:$F$23,$D$4:$D$23,D4,$G$4:$G$23,"<="&H4,$K$4:$K$23,1)-
SUMIFS($E$4:$E$23,$D$4:$D$23,D4,$H$4:$H$23,"<="&H4)

In you previous post

3- For item A in 2014 we Purchase another 250 Pc so we have 350 PC, and sum of sold Q is 190 Pc so we have 60 Pc in end of selling  year 2014 in stock

 

Actually 350-190 is equal to 160, not 60