VLOOKUP That Ignores 0 values

Browneh89

Board Regular
Joined
Mar 8, 2019
Messages
55
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am attempting to find a lookup formula which ignores a value in a table and returns to me the value I require.

Below is an example of what I'm attempting to do;

Example.xlsx
ABCDEFGHIJKL
1Table 1Result Im GettingTable 2Table 3
2LaneREQREQ2LaneID REQ1REQ2IDREQREQ2
310STORE010114STORE0114STORE
4120010114STORE0224HOLD
5140HOLD1020000
616STORE01220000
7180012114STORE0
8142240HOLD
9142240HOLD
10Table 1Result I Want1430000
11LaneREQREQ216114STORE0
1210STORE01830000
1312STORE01830000
14140HOLD182240HOLD
1516STORE0
16180HOLD
17
Sheet1


Specific ID's have Requirements and those ID's are attached to a lane.

In table 1 I want the Lane to show the Requirement however because multiple ID's in Table 2 show up which cause the lookup to fail in table 1.

Is the a simple formula which will allow the lookup to ignore the 0's and just return the Requirement value from table 2.

Any help would be appreciated!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hey, you can use index to ignore those rows with zero entry, in your sheet above try using the formula:

=IF(COUNTIFS(H$4:H$15,"<>0",$F$4:$F$15,$B13)=0,0,INDEX(H$4:H$15,MATCH(1,((H$4:H$15<>0)*($F$4:$F$15=$B13)),0)))

COUNTIFS(H$4:H$15,"<>0",$F$4:$F$15,$B13) - Checking if you have no non-zero entries for a given lane, if so return 0

INDEX(H$4:H$15,MATCH(1,((H$4:H$15<>0)*($F$4:$F$15=$B13)),0))) - Finding the first instance of a non-zero entry that also matches the lane number you're looking for

this works because within an index function in excel will evaluate what you pass in as vectors, so the match witin the index function will result in a single row number, the first non=zero entry ((H$4:H$15<>0)) where lane is equal to the lane number in your row (($F$4:$F$15=$B13))
 
Upvote 0
Hey, you can use index to ignore those rows with zero entry, in your sheet above try using the formula:

=IF(COUNTIFS(H$4:H$15,"<>0",$F$4:$F$15,$B13)=0,0,INDEX(H$4:H$15,MATCH(1,((H$4:H$15<>0)*($F$4:$F$15=$B13)),0)))

COUNTIFS(H$4:H$15,"<>0",$F$4:$F$15,$B13) - Checking if you have no non-zero entries for a given lane, if so return 0

INDEX(H$4:H$15,MATCH(1,((H$4:H$15<>0)*($F$4:$F$15=$B13)),0))) - Finding the first instance of a non-zero entry that also matches the lane number you're looking for

this works because within an index function in excel will evaluate what you pass in as vectors, so the match witin the index function will result in a single row number, the first non=zero entry ((H$4:H$15<>0)) where lane is equal to the lane number in your row (($F$4:$F$15=$B13))
Hey,

Sorry for the late response I have been really busy.

Thanks for your help. the are parts of this formula I do not understand.

=IF(COUNTIFS(H$4:H$15,"<>0",$F$4:$F$15,$B13)=0,0,INDEX(H$4:H$15,MATCH(1,((H$4:H$15<>0)*($F$4:$F$15=$B13)),0)))

Why does the formula reference B13 the Store restriction when it's looking up in the column for the HOLD restriction. Could I not replace =$B13 with ="STORE" or ="HOLD"?
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEFGHIJKL
1Table 1Table 2Table 3
2LaneREQREQ2LaneID REQ1REQ2IDREQREQ2
310STORE010114STORE0114STORE
412STORE010114STORE0224HOLD
5140HOLD1020000
616STORE01220000
7180HOLD12114STORE0
8142240HOLD
9142240HOLD
101430000
1116114STORE0
121830000
131830000
14182240HOLD
Summary
Cell Formulas
RangeFormula
B3:C7B3=INDEX(FILTER(G$3:G$14,($E$3:$E$14=$A3)*(G$3:G$14<>0),0),1)
G3:G14G3=IFNA(VLOOKUP(F3,J:K,2,FALSE),0)
H3:H14H3=IFNA(VLOOKUP(F3,J:L,3,FALSE),0)
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEFGHIJKL
1Table 1Table 2Table 3
2LaneREQREQ2LaneID REQ1REQ2IDREQREQ2
310STORE010114STORE0114STORE
412STORE010114STORE0224HOLD
5140HOLD1020000
616STORE01220000
7180HOLD12114STORE0
8142240HOLD
9142240HOLD
101430000
1116114STORE0
121830000
131830000
14182240HOLD
Summary
Cell Formulas
RangeFormula
B3:C7B3=INDEX(FILTER(G$3:G$14,($E$3:$E$14=$A3)*(G$3:G$14<>0),0),1)
G3:G14G3=IFNA(VLOOKUP(F3,J:K,2,FALSE),0)
H3:H14H3=IFNA(VLOOKUP(F3,J:L,3,FALSE),0)

Unfortunately the version of 365 that i use at work does not have the filter function available :(
 
Upvote 0
Ok, how about
+Fluff 1.xlsm
ABCDEFGHIJKL
1Table 1Table 2Table 3
2LaneREQREQ2LaneID REQ1REQ2IDREQREQ2
310STORE010114STORE0114STORE
412STORE010114STORE0224HOLD
5140HOLD1020000
616STORE01220000
7180HOLD12114STORE0
8142240HOLD
9142240HOLD
101430000
1116114STORE0
121830000
131830000
14182240HOLD
15
Summary
Cell Formulas
RangeFormula
B3:B7B3=IF(COUNTIFS(G:G,"Store",E:E,A3),"STORE",0)
C3:C7C3=IF(COUNTIFS(H:H,"Hold",E:E,A3),"HOLD",0)
G3:G14G3=IFNA(VLOOKUP(F3,J:K,2,FALSE),0)
H3:H14H3=IFNA(VLOOKUP(F3,J:L,3,FALSE),0)
 
Upvote 0
Solution
Ok, how about
+Fluff 1.xlsm
ABCDEFGHIJKL
1Table 1Table 2Table 3
2LaneREQREQ2LaneID REQ1REQ2IDREQREQ2
310STORE010114STORE0114STORE
412STORE010114STORE0224HOLD
5140HOLD1020000
616STORE01220000
7180HOLD12114STORE0
8142240HOLD
9142240HOLD
101430000
1116114STORE0
121830000
131830000
14182240HOLD
15
Summary
Cell Formulas
RangeFormula
B3:B7B3=IF(COUNTIFS(G:G,"Store",E:E,A3),"STORE",0)
C3:C7C3=IF(COUNTIFS(H:H,"Hold",E:E,A3),"HOLD",0)
G3:G14G3=IFNA(VLOOKUP(F3,J:K,2,FALSE),0)
H3:H14H3=IFNA(VLOOKUP(F3,J:L,3,FALSE),0)

Haha Fluffy you seem to solve all my problems.

Thanks very much! This solved the problem easily. I didn't even come close to thinking about using a Countif to solve this.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,428
Messages
6,119,420
Members
448,895
Latest member
omarahmed1

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