Return non-zero data and associated row header from an array

MrNal

New Member
Joined
Jul 24, 2018
Messages
6
I will be grateful for help with the following

I have an array in the following manner:

31/01/2018 28/02/2018 31/03/2018 30/04/2018 31/05/2018 30/06/2018......
First 120 0 145 0 0 20
2nd 0 10 0 6 0 0
.
.

Using a formula I will like to return any non-zero value with their associated date e.g. for First I will like to return the following

120 31/01/2018
145 31/03/2018
20 30/06/2018

The numbers in the array are derived by formula and I can't use traditional index/match because I don't know the date that the non-zero will occur beforehand. I know the column headers that will have the non zero- values

Will be grateful for help with formula that can achieve what I want.

Many thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
For this example, let's assume that A1:G3 contains the data. For the First, try...

I2:

=COUNTIF(B2:G2,">0")

J2, copied down:

=IF(K2<>"",INDEX($B$2:$G$2,MATCH(K2,$B$1:$G$1,0)),"")

K2, confirmed with CONTROL+SHIFT+ENTER, and copied down:

=IF(ROWS(K$2:K2)<=$I$2,INDEX($B$1:$G$1,SMALL(IF($B$2:$G$2>0,COLUMN($B$2:$G$2)-COLUMN($B$2)+1),ROWS(K$2:K2))),"")

Note that the formulas in Column J will only return an empty string ("") until the formulas in Column K have been entered.

Hope this helps!
 
Last edited:
Upvote 0
A slightly different version.
I1 and K1 manually entered.
Formulas in I2:J2 copied down for as many rows as there are dates in the data section (so down to row 7 for this sample)
Then copy I2:J7 to K2 etc

Excel Workbook
ABCDEFGHIJKL
131/01/201828/02/201831/03/201830/04/201831/05/201830/06/2018First2nd
2First1200145002012031/01/20181028/02/2018
32nd010060014531/03/2018630/04/2018
4.2030/06/2018
5.
Non-Zero
 
Upvote 0
Many thanks for taking the time to come up with potential solutions.

Although both suggestions do work to a point, they don't quite work well for my purpose. I need the output to be in be in single colum as I need to then manipulate the data for another purpose. The real struggle is to get the date as I can get the row reference (first 2nd easily). It will be then easy to get data in the array (120,145,20 etc) as I can use index/match to retrieve this once I have a formula return the date.

Will be grateful for suggestions.
 
Upvote 0
I need the output to be in be in single colum ... The real struggle is to get the date as I can get the row reference ...
Is this what you want then?

Excel Workbook
ABCDEFGHIJ
131/01/201828/02/201831/03/201830/04/201831/05/201830/06/2018
2First1200145002031/01/2018
32nd010060031/03/2018
43rd08100022030/06/2018
528/02/2018
630/04/2018
728/02/2018
831/03/2018
931/05/2018
10
Non-Zero
 
Upvote 0
Works exactly the way I want! Thank you very much. Grateful indeed.
Non-Zero

ABCDEFGHIJ
First
2nd
3rd

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:45px;"><col style="width:83px;"><col style="width:83px;"><col style="width:83px;"><col style="width:83px;"><col style="width:83px;"><col style="width:83px;"><col style="width:23px;"><col style="width:22px;"><col style="width:83px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]

[TD="align: right"]31/01/2018[/TD]
[TD="align: right"]28/02/2018[/TD]
[TD="align: right"]31/03/2018[/TD]
[TD="align: right"]30/04/2018[/TD]
[TD="align: right"]31/05/2018[/TD]
[TD="align: right"]30/06/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

[TD="align: right"]120[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]145[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]20[/TD]

[TD="align: right"]31/01/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]

[TD="align: right"]0[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]

[TD="align: right"]31/03/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]

[TD="align: right"]0[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]0[/TD]

[TD="align: right"]30/06/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]

[TD="align: right"]28/02/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]

[TD="align: right"]30/04/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]

[TD="align: right"]28/02/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]8[/TD]

[TD="align: right"]31/03/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]9[/TD]

[TD="align: right"]31/05/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]10[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
J2=IFERROR(INDEX(B$1:G$1,RIGHT(AGGREGATE(15,6,(ROW(B2:G4)*10^6+COLUMN(B$1:G$1)-COLUMN(B$1)+1)/(B$2:G$4<>0),ROWS(J$2:J2)),6)),"")

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4 [/QUOTE]
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,203
Members
452,617
Latest member
Narendra Babu D

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