Question

I'm trying to generate a formula that will pull information from another sheet in the workbook.

I have 1 sheet named "Views" that contains these columns:

ReportName  QueryName   ViewName    ViewAlias

and on sheet 2 named "Items" I have :

ReportName  QueryName   FindViewName    ViewName    ViewAlias FieldName

Only, ViewName is blank and I need to populate it. Currently I have this formula

=IF(ISERROR(VLOOKUP(E3,Views,1)), "", (VLOOKUP(E3, Views, 1)))

in the "FindViewName" column. However "ViewAlias" is not distinct so some items pull back nothing.

In order to find the "ViewName" for these columns I need to compare "ReportName" "QueryName" and "ViewAlias" on each sheet. If they match I want it to fill "ViewName" with the information from the "Views" sheet.

I cannot seem to figure out a way to make this happen and only keep getting errors. If anyone could offer a suggestion it would be extremely helpful!

Était-ce utile?

La solution

Create a new calculated column on Sheet1 titled key and for row 2 make it:

=$a2&"."&$b2&"."&d2

copy that down for all rows (hopefully your using Excel Tables so this happens automatically!)

On Sheet 2, for ViewName column enter in row 2:

=INDEX(sheet1!$D:$D,MATCH($a2&"."&$b2&"."&d2,sheet1!$D:$D,0))

copy that down for all rows (again, hopefully your using Excel Tables so this happens automatically!)

if you're using Tables you can modify this to reference the data items easily by editing the formula, and selecting the ranges

Autres conseils

The very easiest way to do this is to create a "helper" column as follows:

Suppose:

Views Sheet:

Col A:      Col B:      Col C:      Col D:       Col E:
ReportName  QueryName   ViewName    ViewAlias    Helper
                                                 =A2 & "|" & B2 & "|" & D2

Items Sheet:

Col A:      Col B:      Col C:         Col D:      Col E:        Col F:      Col G:
ReportName  QueryName   FindViewName   ViewName    ViewAlias     FieldName   Helper
                                       =OFFSET(Views!$A$1,MATCH(G2,Views!$E:$E,0)-1,2)                                      =A2 & "|" & B2 & "|" & E2

In effect, you're creating a grouping of the elements you want to check against using the =A2 & "|" & B2 & "|" & E2 formula in the helper column, then you're finding the row that matches it in the Views sheet (MATCH(G2,Views!$E:$E,0) and pulling the data from Column C of that row.

Hope this makes sense.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top