?
Solved

Dynamically returning the cell position of a field in a pivot

Posted on 2012-04-12
3
Medium Priority
?
259 Views
Last Modified: 2012-04-13
Hi,

I have a pivot with data about search rankings.
The data consists of keywords matching webpages for many given positions.

Objectives: to build a formula that retrieves the rank of each keyword on a per webpage basis such as this one:
=(GETPIVOTDATA(TEXT("Rank",),$A$1,"Product","Internet","Webpage",$A$5,"Keyword",$A5))

Constraint:the formula needs to be pasted into a very long column alongside the companion pivot table without any modification.

The Catch: some keywords are associated with more than one webpage. Therefore, the hardcoded "Webpage" cell position ($A$5) in the formula above has to be modified as often as there are webpages in the pivot table...

Goal: to replace any hardcoded reference to the "Webpage" ($A$5 in the formula above)
by something dynamic (address, match, find ???) which would
- look for the closest cell above with a string containing "http://",
- return its position and
- feed it to the getpivotdata formula

I have included a spreadsheet to illustrate the situation.

Thanks for the time you take to review this request for help

fg
20120412-getpivotdata-parentfiel.xlsx
0
Comment
Question by:fredericgilbert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
dlmille earned 2000 total points
ID: 37840908
*** Edited ***

LOOKUP approach, put this in cell D5 and copy down:
[D2]=IFERROR(GETPIVOTDATA(TEXT($B$4,),$A$1,"Product",$B$2,"Webpage",LOOKUP(2,1/(LEFT($A$5:$A5,4)="http"),$A$5:A5),"Keyword",$A5),"")


The LOOKUP function finds the last row in column A starting with "http" and has built-in array functionality so CTRL-SHIFT-ENTER is not required so should be more efficient than those type of array functions deriving the same result (tho, I may stand corrected!)

For more on the LOOKUP function and how it works in this instance, see this tip:
http:/Q_27669653.html#a37829864

See attached.

Dave
20120412-getpivotdata-parentfiel.xlsx
0
 

Author Comment

by:fredericgilbert
ID: 37842212
Hello Dave,

I accept your solution for my situation.
 
More important, you just teached me a neat trick with the (2,1/(A:A<>""),A:A) part, very informative with the linked explanations.

Thanks a lot, much appreciated.

fg


Note: yesternight, I worked on it and came up with a cumbersome solution that provided me with the cell position:

=IF(ISERROR(CELL("address",INDEX(a:a,MATCH(VLOOKUP(a28,URL,1,FALSE),a:a,0)))),OFFSET(b27,0,0),(CELL("address",INDEX(a:a,MATCH(VLOOKUP(a28,URL,1,FALSE),a:a,0)))))

Benching against a named range listing all the URLs and upon an error, I was able to retrieve the position of the above cell containing the url then feed it back into the getpivotdata formula to extract the rank...
0
 

Author Closing Comment

by:fredericgilbert
ID: 37842249
The provided solution is simple yet effective.

However, the most valuable takeaway from Dave resides in the linked information from a previous contribution he made that explains how the Lookup(2,1/(A:A<>""),A:A) works.

See: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_27669653.html#a37829864

I learned something important here.
Thanks Dave for your comprehensive solution.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question