Need help with excel formulas

%3CLINGO-SUB%20id%3D%22lingo-sub-2372875%22%20slang%3D%22en-US%22%3ENeed%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2372875%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20I%20am%20currently%20trying%20to%20digitalize%20a%20few%20things%20at%20work%20and%20I%20am%20having%20trouble%20finding%20a%20formula%20that%20will%20automatically%20take%204%20of%20the%20most%20recent%20months%20and%20there%20data%20and%20move%20it%20to%20another%20sheet%20only%20if%20it%20has%20numbers%20that%20are%20not%200%20the%20chart%20is%20a%20simple%20one%20with%20one%20column%20with%20months%20and%20the%20other%20is%20with%20the%20quantity%20of%20parts%20inspected.%3C%2FP%3E%3CP%3ESorry%20if%20its%20not%20very%20clear%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220210520_125810.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282241iE2CB1EB2D642A416%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2220210520_125810.jpg%22%20alt%3D%2220210520_125810.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2372875%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2373048%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2373048%22%20slang%3D%22en-US%22%3E1%20-%20What%20version%20of%20Excel%20do%20you%20run%3F%3CBR%20%2F%3E2%20-%20In%20your%20pic%20only%203%20%22months%22%20with%20Qty%20%26gt%3B%200%20and%20you%20want%20to%20take%20the%204%20most%20recent%20%22months%22.%20So%2C%20what%20should%20happen%20in%20the%20current%20scenario%20(only%203%20%22months%22)%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2375569%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2375569%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F75890%22%20target%3D%22_blank%22%3E%40L%20z.%3C%2FA%3E%26nbsp%3BIm%20running%20the%202016%20version%20and%20i%20have%20a%20table%20on%20a%20different%20sheet%20that%20has%203%20periods(Months)%20and%20one%20for%20the%20current%20month%20i%20would%20like%20to%20be%20able%20to%20have%20the%202%20or%203%20if%20there%20is%20one%20older%20months%20go%20into%20the%203%20older%20period%20spots%20and%20if%20there%20is%20only%202%20it%20would%20just%20leave%20one%20of%20the%20spots%20blank%20and%20with%20the%20current%20month%20will%20get%20put%20into%20the%20current%20month%20spot%20if%20that%20is%20possible%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2375995%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2375995%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1059221%22%20target%3D%22_blank%22%3E%40TMan5757%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETwo%20solutions%20depending%20on%20your%20version.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2375891%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2375891%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1059221%22%20target%3D%22_blank%22%3E%40TMan5757%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20recommend%20(easier%20%26amp%3B%20more%20clear)%20that%20you%20format%20the%202%20columns%20range%20showed%20in%20your%20picture%20as%20a%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fformat-an-excel-table-6789619f-c889-495c-99c2-2f971c0e2370%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETable%3C%2FA%3E%26nbsp%3Band%20name%20the%20columns%20Month%20%26amp%3B%20QTY%20(as%20in%20your%20pic.).%20Now%2C%20let's%20assumed%20it's%20named%26nbsp%3B%3CSTRONG%3ETable1%3C%2FSTRONG%3E.%20In%20your%20other%20sheet%2C%20(not%20mandatory%20but%20more%20clear)%2C%20name%20the%20cell%20(i.e.%20%3CEM%3E%3CSTRONG%3ECurrentMonth%3C%2FSTRONG%3E%3C%2FEM%3E)%20with%20your%20current%20month%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Demo.png%22%20style%3D%22width%3A%20270px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282658i8162B06C56B3912E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Demo.png%22%20alt%3D%22Demo.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ein%26nbsp%3B%3CSTRONG%3EB2%20%3C%2FSTRONG%3Eand%20copy%20down%20until%20%3CSTRONG%3EB4%3C%2FSTRONG%3E%20(Edited%20as%20initial%20didn't%20work%20in%20some%20scenario)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DIF(%0A%20ROWS(B1%3AB%243)%20%26gt%3B%20COUNTIFS(Table1%5BMonth%5D%2C%22%26lt%3B%22%20%26amp%3B%20CurrentMonth%2C%20Table1%5BQTY%5D%2C%22%26gt%3B0%22)%2C%20%22%22%2C%0A%20AGGREGATE(14%2C6%2CTable1%5BMonth%5D%2F((Table1%5BMonth%5D%20%26lt%3B%20CurrentMonth)*(Table1%5BQTY%5D%20%26gt%3B%200))%2CROWS(B1%3AB%243))%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%26nbsp%3B%3CSTRONG%3EC2%20%3C%2FSTRONG%3Eand%20copy%20down%20until%20%3CSTRONG%3EC4%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(B2%20%3D%20%22%22%2C%20%22%22%2C%20INDEX(Table1%5BQTY%5D%2C%20MATCH(B2%2CTable1%5BMonth%5D)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECorresponding%20sample%20is%20attached%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2384598%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20excel%20formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2384598%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F428790%22%20target%3D%22_blank%22%3E%40Patrick2788%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20help%20but%20I%20am%20currently%20having%20trouble%20with%20this%20formula%20and%20i%20attached%20what%20i%20am%20working%20minus%20a%20few%20things%20and%20if%20you%20could%20let%20me%20know%20where%20i%20went%20wrong%20with%20it%20that%20would%20be%20awesome%20thanks%20again%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

So I am currently trying to digitalize a few things at work and I am having trouble finding a formula that will automatically take 4 of the most recent months and there data and move it to another sheet only if it has numbers that are not 0 the chart is a simple one with one column with months and the other is with the quantity of parts inspected.

Sorry if its not very clear

20210520_125810.jpg

 

4 Replies
1 - What version of Excel do you run?
2 - In your pic only 3 "months" with Qty > 0 and you want to take the 4 most recent "months". So, what should happen in the current scenario (only 3 "months")?

@L z. Im running the 2016 version and i have a table on a different sheet that has 3 periods(Months) and one for the current month i would like to be able to have the 2 or 3 if there is one older months go into the 3 older period spots and if there is only 2 it would just leave one of the spots blank and with the current month will get put into the current month spot if that is possible

@TMan5757 

I would recommend (easier & more clear) that you format the 2 columns range showed in your picture as a Table and name the columns Month & QTY (as in your pic.). Now, let's assumed it's named Table1. In your other sheet, (not mandatory but more clear), name the cell (i.e. CurrentMonth) with your current month

 

Demo.png

in B2 and copy down until B4 (Edited as initial didn't work in some scenario):

 

=IF(
 ROWS(B1:B$3) > COUNTIFS(Table1[Month],"<" & CurrentMonth, Table1[QTY],">0"), "",
 AGGREGATE(14,6,Table1[Month]/((Table1[Month] < CurrentMonth)*(Table1[QTY] > 0)),ROWS(B1:B$3))
)

 

in C2 and copy down until C4:

 

=IF(B2 = "", "", INDEX(Table1[QTY], MATCH(B2,Table1[Month])))

 

 

Corresponding sample is attached

@TMan5757 

Two solutions depending on your version.