SOLVED

How to pull the Last Non blank value based on Category - (Contract id and Month)

%3CLINGO-SUB%20id%3D%22lingo-sub-2960088%22%20slang%3D%22en-US%22%3EHow%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2960088%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20currently%20working%20on%20this%20project%20where%20I%20need%20to%20pull%20data%20from%20a%20%60Master%20Data%20Changes%60%20sheet%20into%20an%20%60Analysis%60%20sheet%20based%20on%20contract%20ID.%20In%20the%20%60Master%20Data%20Changes%60%20sheet%20I%20have%20this%20Max%20Dollar%20amount%20old%20(Column%20L)%20and%20Max%20dollar%20new%20column%20(Column%20M)%20which%20showcase%20when%20the%20user%20changed%20the%20dollar%20amount%20to%20which%20value.%20I%20want%20to%20pull%20the%20last%20nonblank%20of%20column%20M%20of%20%60Master%20data%20change%20sheet%20%60%20value%20into%20%60column%20R%60%20of%20%60Analysis%60%20sheet.%20Logic%20of%20this%20formula%20I%20am%20planning%20to%20work%20out%20is%20-%20If%20a%20particular%20contract%20in%20the%20analysis%20sheet%20if%20there%20is%20no%20change%20in%20the%20master%20data%20for%20that%20month%20in%20that%20case%20I%20need%20to%20pull%20the%20previous%20month's%20new%20value(column%20M)%20for%20the%20same%20contract.%20%3CSTRONG%3ERight%20now%20I%20am%20not%20able%20to%20pull%20the%20last%20non-blank%20value%20of%20the%20previous%20month%3C%2FSTRONG%3E%20because%20there%20are%20some%20blank%20values%20in%20the%20same%20month%20that%20I%20can%60t%20delete%20as%20those%20are%20present%20because%20there%20are%20other%20columns%20are%20present%20along%20with%20it.%20Note%3A%20Column%20R%20of%20the%20Analysis%20sheet%20has%20the%20formula%20which%20I%20am%20originally%20planning%20but%20it's%20not%20working%20as%20I%20planned.%26nbsp%3B%20I%20have%20copy-pasted%20the%20part%20of%20this%20formula%20that%20needs%20to%20be%20worked%20upon%20in%20column%20S%20of%20the%20analysis%20sheet.%20I%20am%20getting%20the%20values%20of%20the%20first%20month's%20first%20occurence.%20I%20need%20the%20last%20nonblank%20value.%20In%20the%20sample%20file%20in%20column%20r%20of%20the%20%60Analysis%60%20sheet%2C%20you%20will%20see%20it%20has%20picked%20up%20value%205%20(m4%20cell)%20instead%20of%206%20(m6%20cell).%3CBR%20%2F%3EI%20hope%20I%20am%20clear%20with%20my%20query!%20Any%20help%20would%20be%20really%20appreciated!%3CBR%20%2F%3ERegards%2C%3C%2FP%3E%3CP%3EJM%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2960088%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%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-2960345%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2960345%22%20slang%3D%22en-US%22%3EOK%20I%20really%20got%20lost%20in%20your%20formula%20so%20instead%20of%20trying%20to%20parse%20out%20what%20you%20are%20doing%20here%20is%20my%20formula%20to%20find%20the%20last%20non-blank%20value%20in%20column%20M%20of%20the%20prior%20month%3A%3CBR%20%2F%3E%3DIFERROR(INDEX('Master%20Data%20Changes'!M%3AM%2C1%2F(1%2FMAX(ROW('Master%20Data%20Changes'!M%3AM)*ISNUMBER('Master%20Data%20Changes'!M%3AM)*IFERROR((I2-1)%3DEOMONTH(DATEVALUE('Master%20Data%20Changes'!I%3AI%26amp%3B%22%20%22%26amp%3B'Master%20Data%20Changes'!H%3AH)%2C0)%2CFALSE))))%2C0)%3CBR%20%2F%3EThat%20said%2C%20your%20calculation%20%2F%20expected%20value%20appears%20to%20be%20wrong%20as%20the%20M4%20-%20M6%20cells%20are%20from%20NOV%20not%20DEC%3CBR%20%2F%3EI%20am%20filtering%20for%20LAST%20month%20based%20on%3A%20IFERROR((I2-1)%3DEOMONTH(DATEVALUE('Master%20Data%20Changes'!I%3AI%26amp%3B%22%20%22%26amp%3B'Master%20Data%20Changes'!H%3AH)%2C0)%3CBR%20%2F%3Ewhich%20uses%20column%20I%20(period%20start)%20-%201%20to%20get%20last%20day%20of%20the%20previous%20month%20and%20compare%20with%20End%20Of%20Month%20based%20on%20the%20month%20and%20year.%20It%20is%20rather%20clunky%20and%20would%20be%20nice%20if%20you%20just%20had%20an%20actual%20date%20to%20use%20instead%20but%20I%20was%20working%20with%20what%20you%20have%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2967234%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2967234%22%20slang%3D%22en-US%22%3EHey%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%2C%20Thanks%20for%20your%20quick%20response!%20After%20looking%20at%20your%20solution%20I%20believe%20there%20is%20a%20misunderstanding%20due%20to%20my%20explanation.%20When%20I%20copy-pasted%20your%20formula%20above%20in%20the%20Analysis%20sheet%20I%20am%20getting%20zero%20value%20instead%20of%206%20(M6%20Cell)%20which%20is%20the%20last%20non-blank%20value%20in%20Column%20M%20for%20that%20particular%20contract%2011935.%20I%20believe%20your%20formula%20is%20pulling%20the%20December%20month%20data%20which%20is%20completely%20blank%20that%20I%20don%60t%20need.%20The%20reason%20I%20have%20taken%20blank%20December%20month%20is%20that%20there%20is%20a%20possibility%20the%20previous%20month%20is%20completely%20blank%20but%20the%20month%20before%20that%20i.e.%20November%20month%20has%20some%20non-blank%20value%20in%20column%20M%20which%20I%20need%20to%20pull.%20Also%2C%20one%20more%20thing%20you%20might%20have%20observed%20in%20November%20month%20there%20is%20a%20specific%20blank%20row%20I%20have%20inserted%20intentionally%20%60November%204%60.%20Because%20there%20is%20the%20possibility%20of%20having%20that%20in%20real%20master%20data.%20Thus%20we%20need%20to%20pull%20specifically%20the%20last%20nonblank%20value%20before%20the%20current%20month%20which%20is%206%20in%20this%20sample%20data%20at%20November%203%20Line.%20I%20hope%20I%20have%20made%20my%20problem%20clearer.%20Looking%20forward%20to%20your%20response!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2967996%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2967996%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1216959%22%20target%3D%22_blank%22%3E%40jayant_mandhare%3C%2FA%3E%26nbsp%3B%20so%20am%20i%20understanding%20that%20you%20want%20the%20last%20value%20before%20this%20month.%26nbsp%3B%20So%20all%20I%20had%20to%20do%20was%20tweak%20the%20last%20part%20of%20the%20formula%20to%20be%20%26lt%3B%3D%20instead%20of%20%3D.%26nbsp%3B%20I%20am%20attaching%20the%20updated%20version%20and%20I%20hope%20this%20is%20what%20you%20meant%2Fneed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2971138%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2971138%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%2C%20thanks%20for%20your%20quick%20response!%20After%20validating%20the%20formula%20with%20the%20Another%20contract%20id%20the%20formula%20it%20is%20not%20working%20as%20required.%20When%20I%20inserted%20new%20contract%20%6011930%60%20transaction%20record%20in%20the%20analysis%20sheet%20it%20still%20picked%20up%20the%20value%20of%20the%20%6011935%60%20contract.%20After%20going%20through%20your%20formula%20it%20seems%20you%20just%20considered%20only%20month%20%26amp%3B%20year%20for%20reference%20but%20contract%20id%20(column%20E%20of%20Analysis%20sheet)%20is%20a%20key%20column%20based%20on%20which%20I%20need%20to%20check%20the%20%60master%20data%20changes%60%20is%20missing.%20In%20this%20analysis%20dataset%2C%20there%20could%20be%20multiple%20contracts%20and%20every%20contract%20needs%20to%20be%20treated%20as%20per%20their%20own%20master%20data.%20In%20the%20file%20attached%20you%20will%20see%20in%20the%20analysis%20sheet%20in%20S8%20cell%2C%20I%20need%20the%20m3%20value%20of%20the%20master%20data%20sheet%20.i.e%204%20but%20it's%20picking%20up%208%20right%20now.%20Please%20email%20me%20if%20you%20have%20more%20questions%20we%20could%20have%20quick%20chat%20over%20there.%20my%20email%20id-%20jayantmandhare%40gmail.com.%20Thanks%20in%20advance%20for%20your%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2972457%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2972457%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1216959%22%20target%3D%22_blank%22%3E%40jayant_mandhare%3C%2FA%3E%26nbsp%3BYou're%20right%20I%20didn't%20know.%26nbsp%3B%20I%20have%20added%20that%20as%20a%20criteria%20in%20this%20version.%26nbsp%3B%20I%20also%20formatted%20both%20tables%20as%20tables%20and%20gave%20a%20structured%20reference%20version%20because%20that%20will%20limit%20the%20comparisons%20to%20only%20the%20table%20area%20and%20the%20tables%20will%20grow%20with%20the%20data%20(i.e.%20more%20efficient%20method).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2972822%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2972822%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E-%20thank%20you%20so%20much%20for%20your%20help!%20Really%20appreciate%20it!%20it's%20amazing%20to%20see%20the%20logic%20is%20working%20fine%20right%20now.%20I%20would%20like%20to%20ask%20one%20final%20favor%20from%20you.%20I%20need%20to%20do%20a%20similar%20thing%20with%20the%20%60L%60%20column%20of%20the%20%60Master%20data%20changes%60%20sheet.%20From%20this%20column%2C%20I%20need%20to%20pick%20up%20the%20first%20non-blank%20value%20by%20contract%20id%20eg%3A%20(L2%20cell%20for%20contract%2011930%2F%20L4%20cell%20for%20contract%2011935)%20instead%20of%20the%20last%20nonblank%20value%20which%20you%20did%20in%20the%20previous%20version.%20There%20could%20be%20a%20possibility%20the%20first%20value%20would%20be%20blank%20so%20we%20need%20to%20move%20below%20that%20and%20check%20if%20it%20has%20any%20nonblank%20value.%20If%20it%20has%200%20or%20any%20other%20amount%20I%20need%20to%20pull%20that%20value.%20It%20would%20be%20great%20if%20you%20could%20provide%20fox%20for%20this.%3F%20Once%20I%20get%20this%20part%20of%20the%20formula%20I%20would%20be%20able%20to%20incorporate%20both%20of%20these%20foxes%20in%20my%20original%20formula.%20Let%20me%20know%20if%20you%20have%20any%20queries.%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2982526%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20pull%20the%20Last%20Non%20blank%20value%20based%20on%20Category%20-%20(Contract%20id%20and%20Month)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2982526%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E-%20Hi%20Matt%20did%20you%20get%20any%20chance%20to%20look%20at%20the%20final%20request%20I%20have%20written%20in%20the%20previous%20message.%20That%20would%20be%20the%20final%20piece%20for%20my%20formula%20to%20work%20properly.%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

I am currently working on this project where I need to pull data from a `Master Data Changes` sheet into an `Analysis` sheet based on contract ID. In the `Master Data Changes` sheet I have this Max Dollar amount old (Column L) and Max dollar new column (Column M) which showcase when the user changed the dollar amount to which value. I want to pull the last nonblank of column M of `Master data change sheet ` value into `column R` of `Analysis` sheet. Logic of this formula I am planning to work out is - If a particular contract in the analysis sheet if there is no change in the master data for that month in that case I need to pull the previous month's new value(column M) for the same contract. Right now I am not able to pull the last non-blank value of the previous month because there are some blank values in the same month that I can`t delete as those are present because there are other columns are present along with it. Note: Column R of the Analysis sheet has the formula which I am originally planning but it's not working as I planned.  I have copy-pasted the part of this formula that needs to be worked upon in column S of the analysis sheet. I am getting the values of the first month's first occurence. I need the last nonblank value. In the sample file in column r of the `Analysis` sheet, you will see it has picked up value 5 (m4 cell) instead of 6 (m6 cell).
I hope I am clear with my query! Any help would be really appreciated!
Regards,

JM

8 Replies
OK I really got lost in your formula so instead of trying to parse out what you are doing here is my formula to find the last non-blank value in column M of the prior month:
=IFERROR(INDEX('Master Data Changes'!M:M,1/(1/MAX(ROW('Master Data Changes'!M:M)*ISNUMBER('Master Data Changes'!M:M)*IFERROR((I2-1)=EOMONTH(DATEVALUE('Master Data Changes'!I:I&" "&'Master Data Changes'!H:H),0),FALSE)))),0)
That said, your calculation / expected value appears to be wrong as the M4 - M6 cells are from NOV not DEC
I am filtering for LAST month based on: IFERROR((I2-1)=EOMONTH(DATEVALUE('Master Data Changes'!I:I&" "&'Master Data Changes'!H:H),0)
which uses column I (period start) - 1 to get last day of the previous month and compare with End Of Month based on the month and year. It is rather clunky and would be nice if you just had an actual date to use instead but I was working with what you have

Hey @mtarler, Thanks for your quick response! After looking at your solution I believe there is a misunderstanding due to my explanation. When I copy-pasted your formula above in the Analysis sheet I am getting zero value instead of 6 (M6 Cell) which is the last non-blank value in Column M for that particular contract 11935. I believe your formula is pulling the December month data which is completely blank that I don`t need. The reason I have taken blank December month is that there is a possibility the previous month is completely blank but the month before that i.e. November month has some non-blank value in column M which I need to pull. Also, one more thing you might have observed in November month there is a specific blank row I have inserted intentionally `November 4`. Because there is the possibility of having that in real master data. Thus we need to pull specifically the last nonblank value before the current month which is 6 in this sample data at November 3 Line. I hope I have made my problem clearer. Looking forward to your response!

@jayant_mandhare  so am i understanding that you want the last value before this month.  So all I had to do was tweak the last part of the formula to be <= instead of =.  I am attaching the updated version and I hope this is what you meant/need.

Hi @mtarler, thanks for your quick response! After validating the formula with the Another contract id the formula it is not working as required. When I inserted new contract `11930` transaction record in the analysis sheet it still picked up the value of the `11935` contract. After going through your formula it seems you just considered only month & year for reference but contract id (column E of Analysis sheet) is a key column based on which I need to check the `master data changes` is missing. In this analysis dataset, there could be multiple contracts and every contract needs to be treated as per their own master data. In the file attached you will see in the analysis sheet in S8 cell, I need the m3 value of the master data sheet .i.e 4 but it's picking up 8 right now. Please email me if you have more questions we could have quick chat over there. my email id- jayantmandhare@gmail.com. Thanks in advance for your help!

best response confirmed by jayant_mandhare (Occasional Contributor)
Solution

@jayant_mandhare You're right I didn't know.  I have added that as a criteria in this version.  I also formatted both tables as tables and gave a structured reference version because that will limit the comparisons to only the table area and the tables will grow with the data (i.e. more efficient method).

@mtarler- thank you so much for your help! Really appreciate it! it's amazing to see the logic is working fine right now. I would like to ask one final favor from you. I need to do a similar thing with the `L` column of the `Master data changes` sheet. From this column, I need to pick up the first non-blank value by contract id eg: (L2 cell for contract 11930/ L4 cell for contract 11935) instead of the last nonblank value which you did in the previous version. There could be a possibility the first value would be blank so we need to move below that and check if it has any nonblank value. If it has 0 or any other amount I need to pull that value. It would be great if you could provide fox for this.? Once I get this part of the formula I would be able to incorporate both of these foxes in my original formula. Let me know if you have any queries. Thanks!

@mtarler- Hi Matt did you get any chance to look at the final request I have written in the previous message. That would be the final piece for my formula to work properly.

@jayant_mandhare  sorry for the delay.  the job that pays the bills was busy, lol.  In any case here is a formula to pull the first value using structured refs:

=INDEX(Table1[changes.maximum_dollar_amount.old],MIN(IF(ISNUMBER(Table1[changes.maximum_dollar_amount.old])*(Table1[contract_id]=[@[contract_id]]),ROW(Table1[changes.maximum_dollar_amount.old]),""))-1)

note that with these formulas I'm assuming the table is at the top of the page with 1 header row and then the data and hence the "-1" at the end of the row index to account for the header in row 1.