How To Lookup Second Non-Zero Value And Return Corresponding Column Header In Excel?

martin88

New Member
Joined
Mar 5, 2014
Messages
4
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi Guys,
I have a data as shown below. I am was able to get the first non-zero value, however I am unable to figure out how to get the second none zero value. See sample data below. I know it could be something pretty simple. The formula I used for the first one is as follow: =INDEX($B$1:$J$1,MATCH(TRUE,INDEX(B2:J2<>0,),0))

1661454779413.png


Anyone can assist? It will be greatly appreciated. (If you can also explain on how to work it out to get the third and fourth non-zero value would be awesome)
Thanks in advance
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Name8/01/228/02/228/03/228/04/228/05/228/06/228/07/228/08/228/09/22First DaySecond DayThird DayFourth Day
John23138/02/228/04/228/08/228/09/22


Enter the following formula in K2, confirm with CONTROL+SHIFT+ENTER, and copy across:

=INDEX($B$1:$J$1,SMALL(IF(ISNUMBER($B$2:$J$2),COLUMN($B$2:$J$2)-COLUMN($B$2)+1),COLUMNS($K2:K2)))

Hope this helps!
 
Upvote 0
Solution
Another option.

Book3
ABCDEFGHIJKLMNO
1Name8/1/20228/2/20228/3/20228/4/20228/5/20228/6/20228/7/20228/8/20228/9/2022Day123
2John2318/2/20228/4/20228/8/2022
Sheet3
Cell Formulas
RangeFormula
M2:O2M2=INDEX($B$1:$J$1,AGGREGATE(15,6,(1/(($B$2:$J$2<>""))*(COLUMN($B$2:$J$2)-COLUMN($B$2)+1)),M1))
 
Upvote 0
If your headings are actual dates (numbers) as they appear to be and in chronological order as shown then you can access those values directly, rather than through INDEX/MATCH

22 08 26.xlsm
ABCDEFGHIJKL
1Name1/08/20222/08/20223/08/20224/08/20225/08/20226/08/20227/08/20228/08/20229/08/2022FirstSecond
2John2312/08/20224/08/2022
Get Date
Cell Formulas
RangeFormula
K2K2=AGGREGATE(15,6,B1:J1/(B2:J2<>""),1)
L2L2=AGGREGATE(15,6,B1:J1/(B2:J2<>""),2)


.. or if you might want more than 2

22 08 26.xlsm
ABCDEFGHIJKLMN
1Name1/08/20222/08/20223/08/20224/08/20225/08/20226/08/20227/08/20228/08/20229/08/2022FirstSecondThirdFourth
2John2312/08/20224/08/20228/08/2022 
3Ann256831/08/20223/08/20224/08/20226/08/2022
Get Date (2)
Cell Formulas
RangeFormula
K2:N3K2=IFERROR(AGGREGATE(15,6,$B$1:$J$1/($B2:$J2<>""),COLUMNS($K:K)),"")
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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