SOLVED

SUMIFS continuously add and Subtract the value of an item in rows in an Inventory Table

%3CLINGO-SUB%20id%3D%22lingo-sub-1362703%22%20slang%3D%22en-US%22%3ESUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1362703%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All!%3CBR%20%2F%3ECan%20anyone%20help%20me%20out%3F%3C%2FP%3E%3CP%3EI%20wanted%20to%20increase%20or%20decrease%20the%20quantity%20of%20a%20same%20item%20according%20to%20the%20transaction%20type%20IN%20or%20OUT%20from%20an%20Inventory%20Table.%20It%20means%20when%20I%20stock%20in%20(IN)%20the%20item%20qty%20will%20add%20up%20and%20when%20stock%20out%20(OUT)%20the%20qty%20will%20less%20it.%20But%20in%20my%20case%20as%20shown%20in%20the%20attached%20screenshot%20the%20quantity%20is%20showing%20same%20in%20all%20rows%20of%20respective%20items.%20I%20needed%20to%20be%20in%20history%20like%20first%20row%20qty%2020%20nos%2C%20then%20the%20next%20row%20qty%20will%20show%2012%20nos%20if%20it%20is%20OUT%20transaction.%3CBR%20%2F%3EThank%20you%20in%20advance%20for%20your%20help.%3C%2FP%3E%3CP%3EThe%20formula%20I%20used%20for%20%22Stock%20Quantity%22%20column%20is%20here%3C%2FP%3E%3CP%3E%3DSUMIFS(%5BQTY%20IN%2FOUT%5D%2C%5BTRANSACTION%20DATE%5D%2C%22%26lt%3B%3D%22%26amp%3BEOMONTH(%5B%40%5BTRANSACTION%20DATE%5D%5D%2C0)%2C%5BITEM%20NO%5D%2C%22%3D%22%26amp%3B%5B%40%5BITEM%20NO%5D%5D%2C%5BIN%20%2F%20OUT%5D%2C%22IN%22)-SUMIFS(%5BQTY%20IN%2FOUT%5D%2C%5BTRANSACTION%20DATE%5D%2C%22%26lt%3B%3D%22%26amp%3BEOMONTH(%5B%40%5BTRANSACTION%20DATE%5D%5D%2C0)%2C%5BITEM%20NO%5D%2C%22%3D%22%26amp%3B%5B%40%5BITEM%20NO%5D%5D%2C%5BIN%20%2F%20OUT%5D%2C%22OUT%22)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1362703%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1362829%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1362829%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F657475%22%20target%3D%22_blank%22%3E%40vppismail%3C%2FA%3E%26nbsp%3BI%20would%20like%20to%20recommend%20you%20to%20insert%20an%20extra%20column%20that%20sets%20the%20quantity%20to%20plus%20or%20minus%20based%20on%20IN%2FOUT.%20Then%20you%20can%20use%20what%20you%20could%20call%20and%20auto-expanding%20SUMIF%20to%20calculate%20the%20closing%20inventory%20after%20each%20transaction%20for%20a%20particular%20item.%20Easiest%20to%20demonstrate%20in%20a%20working%20example.%20Please%20see%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1363860%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1363860%22%20slang%3D%22en-US%22%3E%3CP%3EDear%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20quick%20reply..%3C%2FP%3E%3CP%3EIt%20is%20working%20in%20normal%20cell%20ranges%20but%20in%20a%20table%20it%20is%20not%20working%2C%20it%20showing%20the%20same%20qty%20in%20all%20respective%20item's%20row%20(as%20highlighted%20in%20the%20excel).%3C%2FP%3E%3CP%3EI%20have%20attached%20the%20excel%20file%20for%20your%20reference%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1364302%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1364302%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F657475%22%20target%3D%22_blank%22%3E%40vppismail%3C%2FA%3E%26nbsp%3BIn%20this%20case%2C%20I%20believe%20you%20have%20to%20sacrifice%20the%20structured%20table%20references%20and%20manually%20enter%20the%20first%20and%20last%20range%20in%20the%20following%20in%20N21%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DSUMIF(%24I%246%3AI7%2C%5B%40%5BITEM%20NAME%5D%5D%2C%24M%246%3AM7)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1364431%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1364431%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BIt%20worked%20%2C%20thank%20you%20so%20much%2C%20appreciated.%20%3CLI-EMOJI%20id%3D%22lia_grinning-face-with-smiling-eyes%22%20title%3D%22%3Agrinning_face_with_smiling_eyes%3A%22%3E%3C%2FLI-EMOJI%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1368785%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1368785%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%20Greetings!!%3C%2FP%3E%3CP%3ESorry%20to%20bother%20you%2C%20you%20helped%20me%20a%20lot%20and%20I%20am%20very%20glad%20to%20be%20with%20you.%3C%2FP%3E%3CP%3EThis%20formula%20is%20consistent%2C%20not%20updating%20accordingly%20when%20add%20new%20rows%20in%20this%20table%2C%20so%20if%20it%20is%20possible%20you%20may%20peruse%20the%20attached%20excel%20last%20two%20rows%20and%20also%20please%20try%20to%20add%20new%20rows%20with%20data%20then%20you%20can%20understand%20the%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1369102%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1369102%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F657475%22%20target%3D%22_blank%22%3E%40vppismail%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20notices%20an%20inconsistency%20on%20row%2041.%20The%20last%20element%20in%20the%20formula%20is%20M42.%20It%20should%20be%20M41.%20Can't%20tell%20what%20you%20did%20to%20cause%20this.%20I%20copied%20the%20formula%20from%20the%20row%20above%20to%20the%20rows%20below%20it%20and%20all%20works%20fine.%20Then%2C%20I%20added%20a%20row%20to%20the%20table%20and%20the%20formula%20is%20automatically%20included%20in%20that%20new%20row.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1369182%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1369182%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%20May%20be%20you%20haven't%20noticed%20by%20adding%20row%20by%20pressing%20TAB.%20When%20I%20solve%20by%20clicking%20%22Restore%20to%20calculated%20column%20formula%22%20then%20it%20is%20corrected%20by%20itself.%20When%20I%20add%20new%20row%20by%20pressing%20TAB%20then%20the%20just%20above%20row%20will%20be%20inconsistent%20by%20itself%20changing%20the%20value%20to%20M42%20instead%20of%20M41%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1369282%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1369282%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F657475%22%20target%3D%22_blank%22%3E%40vppismail%3C%2FA%3E%26nbsp%3BI%20see.%20Didn't%20notice%20that%20before.%20I%20guess%20it's%20because%20we%20are%20not%20exactly%20following%20%22best%20practices%22%20here%20by%20violation%20against%20structured%20table%20references.%20Experimented%20a%20little%20and%20found%20that%20if%20the%20formula%20looks%20like%20below%2C%20the%20inconsistencies%20does%20not%20occur.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMIF(%24G%247%3A%40G42%2C%5B%40%5BITEM%20NO%5D%5D%2C%24M%247%3A%40M42)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDon't%20really%20know%20how%20to%20explain%20why%20the%26nbsp%3B%40-sign%20makes%20this%20happen.%20Perhaps%20others%20out%20here%20who%20can%20explain.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1369404%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1369404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BThank%20you%20for%20your%20great%20support.%3C%2FP%3E%3CP%3EAnd%20the%20formula%20is%20not%20working.%3C%2FP%3E%3CP%3EAnyone%20can%20help%20me%20out.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1379528%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1379528%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BI%20got%20it%20from%20another%20excel%20forum%26nbsp%3B%20website%20and%20it%20solved%20by%20using%20this%20formula%20for%20structure%20table%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3DSUMIF(Table14%5B%5B%23Headers%5D%2C%5BITEM%20NO%5D%5D%3AINDEX(G%3AG%2CROW(%5B%40%5BITEM%20NO%5D%5D))%2C%5B%40%5BITEM%20NO%5D%5D%2CTable14%5B%5B%23Headers%5D%2C%5BQTY%20%2B%2F-%5D%5D%3AINDEX(M%3AM%2CROW(%5B%40%5BQTY%20%2B%2F-%5D%5D)))%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1380066%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1380066%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F657475%22%20target%3D%22_blank%22%3E%40vppismail%3C%2FA%3E%26nbsp%3BThanks%20for%20sharing.%20Took%20the%20formula%20to%20test%20it%20in%20a%20schedule%20of%20my%20own.%20I%20learned%20something%20today.%20But%2C%20on%20my%20system%20(Excel%20for%20Mac%20%3CSTRONG%3Eand%3C%2FSTRONG%3E%20Excel%20for%20PC%20on%20a%20virtual%20machine)%2C%26nbsp%3Bthe%20formula%20I%20provided%20earlier%20returns%20the%20same%20outcome.%20Thanks%20again!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1380345%22%20slang%3D%22en-US%22%3ERe%3A%20SUMIFS%20continuously%20add%20and%20Subtract%20the%20value%20of%20an%20item%20in%20rows%20in%20an%20Inventory%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1380345%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BYou%20are%20welcome%2C%20I%20also%20learnt%20a%20lot%20from%20you%2C%20thanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi All!
Can anyone help me out?

I wanted to increase or decrease the quantity of a same item according to the transaction type IN or OUT from an Inventory Table. It means when I stock in (IN) the item qty will add up and when stock out (OUT) the qty will less it. But in my case as shown in the attached screenshot the quantity is showing same in all rows of respective items. I needed to be in history like first row qty 20 nos, then the next row qty will show 12 nos if it is OUT transaction.
Thank you in advance for your help.

The formula I used for "Stock Quantity" column is here

=SUMIFS([QTY IN/OUT],[TRANSACTION DATE],"<="&EOMONTH([@[TRANSACTION DATE]],0),[ITEM NO],"="&[@[ITEM NO]],[IN / OUT],"IN")-SUMIFS([QTY IN/OUT],[TRANSACTION DATE],"<="&EOMONTH([@[TRANSACTION DATE]],0),[ITEM NO],"="&[@[ITEM NO]],[IN / OUT],"OUT")

12 Replies
Highlighted
Best Response confirmed by vppismail (Occasional Contributor)
Solution

@vppismail I would like to recommend you to insert an extra column that sets the quantity to plus or minus based on IN/OUT. Then you can use what you could call and auto-expanding SUMIF to calculate the closing inventory after each transaction for a particular item. Easiest to demonstrate in a working example. Please see attached.

Highlighted

Dear @Riny_van_Eekelen  

Thank you for your quick reply..

It is working in normal cell ranges but in a table it is not working, it showing the same qty in all respective item's row (as highlighted in the excel).

I have attached the excel file for your reference

Highlighted

@vppismail In this case, I believe you have to sacrifice the structured table references and manually enter the first and last range in the following in N21:

=SUMIF($I$6:I7,[@[ITEM NAME]],$M$6:M7)

 

Highlighted

@Riny_van_Eekelen It worked , thank you so much, appreciated.  

 

Highlighted

@Riny_van_Eekelen  Greetings!!

Sorry to bother you, you helped me a lot and I am very glad to be with you.

This formula is consistent, not updating accordingly when add new rows in this table, so if it is possible you may peruse the attached excel last two rows and also please try to add new rows with data then you can understand the issue.

 

Highlighted

@vppismail 

I notices an inconsistency on row 41. The last element in the formula is M42. It should be M41. Can't tell what you did to cause this. I copied the formula from the row above to the rows below it and all works fine. Then, I added a row to the table and the formula is automatically included in that new row.

Highlighted

@Riny_van_Eekelen  May be you haven't noticed by adding row by pressing TAB. When I solve by clicking "Restore to calculated column formula" then it is corrected by itself. When I add new row by pressing TAB then the just above row will be inconsistent by itself changing the value to M42 instead of M41 

Highlighted

@vppismail I see. Didn't notice that before. I guess it's because we are not exactly following "best practices" here by violation against structured table references. Experimented a little and found that if the formula looks like below, the inconsistencies does not occur.

 

=SUMIF($G$7:@G42,[@[ITEM NO]],$M$7:@M42)

 

Don't really know how to explain why the @-sign makes this happen. Perhaps others out here who can explain.

Highlighted

@Riny_van_Eekelen Thank you for your great support.

And the formula is not working.

Anyone can help me out.

Highlighted

@Riny_van_Eekelen I got it from another excel forum  website and it solved by using this formula for structure table

 

=SUMIF(Table14[[#Headers],[ITEM NO]]:INDEX(G:G,ROW([@[ITEM NO]])),[@[ITEM NO]],Table14[[#Headers],[QTY +/-]]:INDEX(M:M,ROW([@[QTY +/-]])))

Highlighted

@vppismail Thanks for sharing. Took the formula to test it in a schedule of my own. I learned something today. But, on my system (Excel for Mac and Excel for PC on a virtual machine), the formula I provided earlier returns the same outcome. Thanks again!

 

 

Highlighted

@Riny_van_Eekelen You are welcome, I also learnt a lot from you, thanks again.