Look up based on 2 seperate columns

mdrew9

Board Regular
Joined
Mar 4, 2006
Messages
118
Not sure if my title is the proper way to describe this.
I have a data table it has 2 columns, Activity and Element. I am trying to "look up" what this record is based on these values. This would be very simple if it was just activity, but its conditional first on element.
What I want to do is this
=IFERROR(VLOOKUP(E6,tblElement,2,FALSE),VLOOKUP(D6,tblActivity,2,FALSE)) In excel this works.

=IFERROR(related(tblElement[Color]),related(Activity[Color])) In Powerpivot this does not work because there is no error

I could also put this in Access as a query before bringing it into PP, so that is also an option.

Also typically in my pivot table I would just include the Color column as on of my fields, so I am calculated what each record is at each line. Not sure if there is a way around this.
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi mdrew9,

You can achieve this type of conditional lookup in PowerPivot with a measure like the one below:

IF(
HASONEFILTER( Table1[colA]) ,
CALCULATE( VALUES(Table2[colB]) , Table1 ) &
CALCULATE( VALUES(Table3[colB]) , Table1 )
)

This assumes you have an actual relationship between your base table and your two lookups; in your case those lookups would be tblElement and tblActivity.
 
Upvote 0
I couldn't quite get that to work, but taking out the if and hasonefilter and just concatenating the two calculates together gives me what I am looking for. Any reason I wouldn't want to do this? And can I do this as a measure and not just put it as a column?

Hi mdrew9,

You can achieve this type of conditional lookup in PowerPivot with a measure like the one below:

IF(
HASONEFILTER( Table1[colA]) ,
CALCULATE( VALUES(Table2[colB]) , Table1 ) &
CALCULATE( VALUES(Table3[colB]) , Table1 )
)

This assumes you have an actual relationship between your base table and your two lookups; in your case those lookups would be tblElement and tblActivity.
 
Upvote 0
as a calculated column, you can use

Related(tableA[column]) & Related(tableB[column])

as a measure you would have to use something like what I posted above.

No reason you would want to go with one or the other, except usability.
 
Upvote 0
Upon further examination, I am getting duplicate values for those cells that are could be populated with both fields.
 
Upvote 0
I see. In those cases, do you have any business rule that would prefer one over the other one?

YES! Mirroring this function "=IFERROR(#1 VLOOKUP(E6,tblElement,2,FALSE),#2 VLOOKUP(D6,tblActivity,2,FALSE)) In excel "

each section ordered by priorty.
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

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