Display the first non-zero occurence in a row in a Pivot table

karthik104

New Member
Joined
Dec 4, 2015
Messages
7
Hi,

I have data in a pivot table:

Row Labels
12/27/2015
1/3/2016
1/10/2016
1/17/20161/24/20161/31/20162/7/20162/14/2016
2/21/20162/28/20163/6/2016
ABB
0
0310
400
500
22
2223
2232
323
6565
655
ABC
777
777
777
777
777
787
7989899989829895698956
XYZ
0
0
328
328
328
328
428
58789878964654
ZMN
0
000000500
500
500
500

<colgroup><col span="2"><col span="10"></colgroup><tbody>
</tbody>

I looking to extract the column (in this case the date) with the first non-zero occurrence for each label:

Output should be like this:

Row Labels
Date
ABB
1/10/2016
ABC
12/27/2015
XYZ
1/10/2016
ZMN
2/14/2016

<tbody>
</tbody>


Any thoughts/suggestions on how to do this?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Here is a way. The formula may be copied downwards but may need to be adjusted for your data ranges.


Excel 2010
ABCDEFGHIJKL
1Row Labels12/27/20151/3/20161/10/20161/17/20161/24/20161/31/20162/7/20162/14/20162/21/20162/28/20163/6/2016
2ABB0031040050022222322323236565655
3ABC7777777777777777877989899989829895698956
4XYZ0032832832832842858789878964654
5ZMN0000000500500
6
7Row LabelsDate
8ABB1/10/2016
9ABC12/27/2015
10XYZ1/10/2016
11ZMN2/14/2016
Sheet8
Cell Formulas
RangeFormula
B8=INDEX(B$1:L$1,IF(TYPE(MATCH(0,B2:L2,1)+1)=16,1,MATCH(0,B2:L2,1)+1))
Named Ranges
NameRefers ToCells
X=trendlines!$A$7:$A$26
Y=trendlines!$B$7:$B$26
 
Upvote 0
In my above post, ignore the workbook defined names. They are part of another project I am working on.
 
Upvote 0
Using tybaltlives's table in post#2, in B8, formula copy down :

=INDEX(B$1:L$1,INDEX(MATCH(TRUE,OFFSET(A$1,MATCH(A8,A$2:A$5,0),1,1,11)>0,0),0))

Regards
 
Upvote 0
Some clarification of the formula used

1] If criteria name are same as the source table order (as post #.1 example):

In B8, formula copy down :

=INDEX(B$1:L$1,INDEX(MATCH(TRUE,B2:L2>0,0),0))

2] If criteria name are not same as the source table order :

In B8, formula copy down :

=INDEX(B$1:L$1,INDEX(MATCH(TRUE,OFFSET(A$1,MATCH(A8,A$2:A$5,0),1,1,11)>0,0),0))

Regards
 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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