I don't know that "denormalize" is technically the correct term, so to you database guys, I apologize up front, but it's the best I could come up with to describe my need.
I am being given the output of a relational database in Excel format, where there is a one-to-many relationship between "person name" and "position code". For each person, one row is output for each position held. The "key" is the name, which is the "one" side of the relationship.
I'm not bad with Excel, but this is beyond my pay grade: I want to have, for each name, a cell that has the concatenated set of positions to which that person is assigned. An example:
Yeah, I ran down the Pivot Table rabbit hole myself; I've seen some very fancy things done with VLOOKUP and am hoping someone clever can put something together, but if VBA is the only solution I'm going to have to go another route :-(
A few questions, please...
(1) In your source example, all of the entries for an individual are grouped together. Is this true for the actual data?
(2) May we add a helper column (or two!) beside the source data?
(3) May we assume a maximum no. of entries?
(4) How does the source data get from the database to the spreadsheet which will contain the results?
Thanks,
Brian.
0
We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Column F has
=IF(COUNTA($E2:E2)>0,E2&", ","")&IF(ISERROR(MATCH($D2&F$1,INDEX($A$1:$A$20&$B$1:$B$20,0),0)),0,F$1)
Hide columns E to H. In column I use
=SUBSTITUTE(SUBSTITUTE(H2,", 0",""),"0, ","")
This can be expanded to as many positions as there are in the data.
You can use a pivot table to set up the initial grid of unique names in the rows and unique list of positions in the column headers. Then copy the unique names and use paste special > values to paste to a new table. Copy the unique position names and paste special > values across the top.
Please see the attached. A few points...
(1) The formulas are in the yellow (and one red) cells. Copy them down for as many as rows as you have data in column A. You can overshoot (as I have in rows 28 to 31) without breaking anything.
(2) If you want to be fancy the formulas in columns F anf H:I only need to go down as many rows as the number of unique names (E2).
(3) The red cell is highlighted because, apologies, its formula is different from the other cells in that column.
(4) If you may have more than 5,000 entries in column A then the formulas in column F need to be changed.
Hello, thanks for closing the question, but can you please explain the B grade? If you don't assign an A grade, you should explain what aspect of the answers you are not happy with, so experts can improve their suggestions.
If you are not happy with the way that Excel works, then that does not mean the question gets a B, though. Experts are not responsible for the way Excel works.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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â€¦
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calculâ€¦