Strip Flat File Table into less entries

I have a table I found that is essentially a 'hierarchical' table but laid 
out in such a way I can't really use it w/o further processing. Essentially 
it is currently something like this

Type | Type Code | Subtype | SubType Code |  SubSubType | SubSubType Code

I really just want to end up with

Type | Type Code | Parent Code

So I might have

Fruit | 100000 |  Citrus | 100100 | Orange |  1001001
Fruit | 100000 |  Citrus | 100100 | Lemon  |  1001002
Fruit | 100000 |  Melon |  100200 | Cantelope | 100201
Fruit | 100000 | Melon  |  100200  | Honeydew | 100202
Meat | 200000 | Beef   |   200100  |  Tenderloin | 200101
Meat | 200000 | Beef  | 200100  |  Brisket   |  200102
Meat  | 200000 | Pork  | 200200  | Bacon  | 200201

and I want
Fruit | 100000 | 
Melon | 100200 | 100000
Cirtus | 100100 | 100000
Orange | 100101| 100100
Lemon   | 100102 | 100100
Cantelope | 100201 | 100200
Honeydew | 100202 | 100200
Meat | 200000
Beef | 200100 | 200000
Pork | 200200 | 200000
Tenderloin | 200101 | 200100
Brisket | 200102 | 200100
Bacon | 200201 | 200200

Is there an easy function I could use to process the sheet thusly? 
0
Utf
12/25/2009 9:50:01 PM
excel.worksheet.functions 4936 articles. 2 followers. Follow

6 Replies
827 Views

Similar Articles

[PageSpeed] 14

Here's one formulas construct which gets you all the way to Rome ...
Assume your source data as posted is in Sheet1, in A2:F2 down
In another sheet,
In A2: 
=OFFSET(Sheet1!$A$2,INT((ROWS($1:1)-1)/3),MOD(ROWS($1:1)-1,3)*2)
In B2:
=OFFSET(Sheet1!$B$2,INT((ROWS($1:1)-1)/3),MOD(ROWS($1:1)-1,3)*2)
Copy A2:B2 down to exhaust the data (until zeros are returned). Cols A and B 
transforms the source data in Sheet1 neatly into 2 cols (and ideal for 
downstream pivot analysis. You just need to put in the col headers into A1:B1)

In D2:
=IF(A2=0,"",IF(COUNTIF(A$2:A2,A2)>1,"",ROW()))
In E2:
=IF(ROWS($1:1)>COUNT(D:D),"",INDEX(A:A,SMALL(D:D,ROWS($1:1))))
Copy E2:D2 down. Col E will return the list of uniques (fruits) from col A 

Put this in F2, array-enter ie press CTRL+SHIFT+ENTER to confirm the formula:
=IF($E2="","",IF(COLUMNS($A:A)>COUNTIF($A$2:$A$1000,$E2),"",INDEX($B$2:$B$1000,SMALL(IF($A$2:$A$1000=$E2,ROW($1:$999)),COLUMNS($A:A)))))
Copy F2 across to I2 (say) -- you should copy across by as many cols 
required to cover the max expected number of corresponding figs per unique 
fruit -- fill down. That should round it up and deliver exactly the final 
results that you seek in cols E to I (hide away/minimize cols A to D). You 
should modify the ranges in the expression in F2 to suit the actual extents 
(I catered for 999 rows. Use the smallest range which is large enough). 
Success? Celebrate it, hit the YES below
-- 
Max
Singapore
--- 
"msnyc07" wrote:
> I have a table I found that is essentially a 'hierarchical' table but laid 
> out in such a way I can't really use it w/o further processing. Essentially 
> it is currently something like this
> 
> Type | Type Code | Subtype | SubType Code |  SubSubType | SubSubType Code
> 
> I really just want to end up with
> 
> Type | Type Code | Parent Code
> 
> So I might have
> 
> Fruit | 100000 |  Citrus | 100100 | Orange |  1001001
> Fruit | 100000 |  Citrus | 100100 | Lemon  |  1001002
> Fruit | 100000 |  Melon |  100200 | Cantelope | 100201
> Fruit | 100000 | Melon  |  100200  | Honeydew | 100202
> Meat | 200000 | Beef   |   200100  |  Tenderloin | 200101
> Meat | 200000 | Beef  | 200100  |  Brisket   |  200102
> Meat  | 200000 | Pork  | 200200  | Bacon  | 200201
> 
> and I want
> Fruit | 100000 | 
> Melon | 100200 | 100000
> Cirtus | 100100 | 100000
> Orange | 100101| 100100
> Lemon   | 100102 | 100100
> Cantelope | 100201 | 100200
> Honeydew | 100202 | 100200
> Meat | 200000
> Beef | 200100 | 200000
> Pork | 200200 | 200000
> Tenderloin | 200101 | 200100
> Brisket | 200102 | 200100
> Bacon | 200201 | 200200
> 
> Is there an easy function I could use to process the sheet thusly? 
0
Utf
12/25/2009 11:28:01 PM
Hey thanks for all that. I did paste in and nothing happened, tried typing by 
hand and get a "Formula contains an error" though :(

"Max" wrote:

> Here's one formulas construct which gets you all the way to Rome ...
> Assume your source data as posted is in Sheet1, in A2:F2 down
> In another sheet,
> In A2: 
> =OFFSET(Sheet1!$A$2,INT((ROWS($1:1)-1)/3),MOD(ROWS($1:1)-1,3)*2)
> In B2:
> =OFFSET(Sheet1!$B$2,INT((ROWS($1:1)-1)/3),MOD(ROWS($1:1)-1,3)*2)
> Copy A2:B2 down to exhaust the data (until zeros are returned). Cols A and B 
> transforms the source data in Sheet1 neatly into 2 cols (and ideal for 
> downstream pivot analysis. You just need to put in the col headers into A1:B1)
> 
> In D2:
> =IF(A2=0,"",IF(COUNTIF(A$2:A2,A2)>1,"",ROW()))
> In E2:
> =IF(ROWS($1:1)>COUNT(D:D),"",INDEX(A:A,SMALL(D:D,ROWS($1:1))))
> Copy E2:D2 down. Col E will return the list of uniques (fruits) from col A 
> 
> Put this in F2, array-enter ie press CTRL+SHIFT+ENTER to confirm the formula:
> =IF($E2="","",IF(COLUMNS($A:A)>COUNTIF($A$2:$A$1000,$E2),"",INDEX($B$2:$B$1000,SMALL(IF($A$2:$A$1000=$E2,ROW($1:$999)),COLUMNS($A:A)))))
> Copy F2 across to I2 (say) -- you should copy across by as many cols 
> required to cover the max expected number of corresponding figs per unique 
> fruit -- fill down. That should round it up and deliver exactly the final 
> results that you seek in cols E to I (hide away/minimize cols A to D). You 
> should modify the ranges in the expression in F2 to suit the actual extents 
> (I catered for 999 rows. Use the smallest range which is large enough). 
> Success? Celebrate it, hit the YES below
> -- 
> Max
> Singapore
> --- 
> "msnyc07" wrote:
> > I have a table I found that is essentially a 'hierarchical' table but laid 
> > out in such a way I can't really use it w/o further processing. Essentially 
> > it is currently something like this
> > 
> > Type | Type Code | Subtype | SubType Code |  SubSubType | SubSubType Code
> > 
> > I really just want to end up with
> > 
> > Type | Type Code | Parent Code
> > 
> > So I might have
> > 
> > Fruit | 100000 |  Citrus | 100100 | Orange |  1001001
> > Fruit | 100000 |  Citrus | 100100 | Lemon  |  1001002
> > Fruit | 100000 |  Melon |  100200 | Cantelope | 100201
> > Fruit | 100000 | Melon  |  100200  | Honeydew | 100202
> > Meat | 200000 | Beef   |   200100  |  Tenderloin | 200101
> > Meat | 200000 | Beef  | 200100  |  Brisket   |  200102
> > Meat  | 200000 | Pork  | 200200  | Bacon  | 200201
> > 
> > and I want
> > Fruit | 100000 | 
> > Melon | 100200 | 100000
> > Cirtus | 100100 | 100000
> > Orange | 100101| 100100
> > Lemon   | 100102 | 100100
> > Cantelope | 100201 | 100200
> > Honeydew | 100202 | 100200
> > Meat | 200000
> > Beef | 200100 | 200000
> > Pork | 200200 | 200000
> > Tenderloin | 200101 | 200100
> > Brisket | 200102 | 200100
> > Bacon | 200201 | 200200
> > 
> > Is there an easy function I could use to process the sheet thusly? 
0
Utf
12/25/2009 11:46:01 PM
Excel 2007 PivotTable
No formulas needed.
Utility for further processing unknown,
but it sure looks appetizing.
http://c0444202.cdn.cloudfiles.rackspacecloud.com/12_25_09.xlsx
0
Herbert
12/25/2009 11:53:16 PM
Best thing to give you is a working example:
http://cjoint.com/?mAbiANHCdV

Success, finally? Thump the air, hit the YES below
-- 
Max
Singapore
--- 
"msnyc07" wrote:
> Hey thanks for all that. I did paste in and nothing happened, tried typing by 
> hand and get a "Formula contains an error" though :(

0
Utf
12/26/2009 12:14:01 AM
Hi thanks for that, I think you might have misunderstood the challenge, my 
fault if so.

I don't need a count it is just that a nested table was presented in a 
clumsy way i.e.

Level 3 | Level 2 | Level 1

which led to lots of duplication since I just wanted
Level 1
 Level 2
  Level 3

All I did was this

Fruit | Citrus | Orange
Fruit | Citrus | Lemon
Meat | Beef | Filet
Meat | Beef | Pork
Vegetable | Green | Broccoli
Vegetable | Green | Lettuce
Vegetable | Orange | Carrot

and copy partial columns down and then got rid of dupes!

Thanks though!

Merry Christmas!


"Max" wrote:

> Best thing to give you is a working example:
> http://cjoint.com/?mAbiANHCdV
> 
> Success, finally? Thump the air, hit the YES below
> -- 
> Max
> Singapore
> --- 
> "msnyc07" wrote:
> > Hey thanks for all that. I did paste in and nothing happened, tried typing by 
> > hand and get a "Formula contains an error" though :(
> 
0
Utf
12/26/2009 12:28:01 AM
Aha, thought I did read your original posting ok, and you did give a 
depiction of the desired results. But maybe you changed your mind somewhere 
along the way. cheers 
-- 
Max
Singapore
--- 
"msnyc07" wrote:
> Hi thanks for that, I think you might have misunderstood the challenge, my 
> fault if so.
> 
> I don't need a count it is just that a nested table was presented in a 
> clumsy way i.e.
> 
> Level 3 | Level 2 | Level 1
> 
> which led to lots of duplication since I just wanted
> Level 1
>  Level 2
>   Level 3
> 
> All I did was this
> 
> Fruit | Citrus | Orange
> Fruit | Citrus | Lemon
> Meat | Beef | Filet
> Meat | Beef | Pork
> Vegetable | Green | Broccoli
> Vegetable | Green | Lettuce
> Vegetable | Orange | Carrot
> 
> and copy partial columns down and then got rid of dupes!
> 
> Thanks though!
> 
> Merry Christmas!

0
Utf
12/26/2009 10:40:01 AM
Reply:

Similar Artilces:

#Delete Mark in Bound Memo filed
I have form that has bound memo field, sometime, no sure how it happen, the memo filed is filled with #Delete. My application is a stand alone program. Kindly advise what can cause this and how to avoid it from happening. -- TS Lim When was the last time you performed a compact and repair? Is you db split? Does each user have their own copy of the front-end? Please checkout http://www.granite.ab.ca/access/corruptmdbs.htm http://www.granite.ab.ca/access/corruption/symptoms.htm http://office.microsoft.com/en-ca/access/HA011865661033.aspx - No very helpful but directly from MS ...

CSV File Problem
Can any one explain why the following problem occurs please? A colleague has a small list of data which is a csv file exported from SQL. Column One is a serial number from 1 to 29. Column 2 is a number of transactions which have occurred.(it should look like example A below in Excel) 1 475 1,475 2 1732 21,732 3 1670 31,670 4 2176 42,176 5 608 5,608 6 1579 61,579 7 43101 743,101 8 54512 854,512 9 51258 951,258 10 61050 1,061,050 A B If I double click on the csv file, it opens in Excel but c...

PA Misc. Log Tables
Hi, How can I find the difference between Billed and Un-billed Miscelleneous Logs? Where Can I see Un-billed Misc. Logs and which tables. Hari I have a spreadsheet with the PA tables listed in it. Send an email message to charles.zarzour@intergraph.com and I will send you the spreadsheet. I do an excel spreadsheet for each Dictionary. Makes it easy to lookup tables. "Hari" wrote: > Hi, > How can I find the difference between Billed and Un-billed Miscelleneous > Logs? > Where Can I see Un-billed Misc. Logs and which tables. > > Hari > > Can I ...

CFile (delete file)
How can I delete all files that end with ".temp" in some folder? CFile::Remove remove unlink -- cheers, Alok Gupta Blogs: http://wdevs.com/thatsalok "Petar Popara" <my.fake@mail.net> wrote in message news:Op6#URKfFHA.2644@TK2MSFTNGP09.phx.gbl... > > How can I delete all files that end with ".temp" in some folder? > > SHFileOperation() will and it supports wildcards! DeleteFile() will operate on one file at a time. "Petar Popara" <my.fake@mail.net> wrote in message news:Op6%23URKfFHA.2644@TK2MSFTNGP09.phx.gbl... > >...

Opening an *.MSG file with it's respective attachment.
Hello, The file *.MSG is a message file. This can be viewed by any editor, like Notepad. However, when there's an attachment to it, we see garbage. Is there a way to open the attachments present inside the *.MSG files ? Thank you Yes, by opening it with Outlook. -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tips of the month: -Create your own fully customized Toolbar -Creating a Classic View in Outlook 2003 Subscribe to the newsletter to receive news and tips & tricks in your mailbox!...

Can't open 2005 data file after reinstalling Money 2005
I am experiencing a recurring problem. I have had to reinstall Windows XP and MS Money 2005. I am now unable to open my previously converted 2005 file or restore any backup version. I consistently get the following error message: "Money cannot locate filename or cannot open it, possibly because it is a read-only file, you do not have permission to change it, or your disk drive is write- protected. If you have chosen the correct file and it cannot be accessed, you will need to click OK and then Restore your most recent backup file." Any help or thoughts would be greatly ap...

import a 123 file
My excel version cannot open a Lotus 123 file. Is there an import feature to move the data from Lotus 123 to Excel? Thanks No, you need to convert the file either from Lotus 123 or get commercial converter -- Regards, Peo Sjoblom "Frank" <Frank@discussions.microsoft.com> wrote in message news:59B55F98-4C79-4917-928B-F1B309660730@microsoft.com... > My excel version cannot open a Lotus 123 file. Is there an import feature > to > move the data from Lotus 123 to Excel? > Thanks > > ...

Where is the cache files folder located for windows media player?
Does windows media player have a cache files folder? Where is the cache files folder located for windows media player? Or how do I find the cache files folder for windows media player? Thank You for your Help. Bob Background info: I have a desktop AMD 4400+ 64X2 4GB memory 320GB HD(way bigger than I need) Acer computer (AM3100-U3201A) I purchased new February 2008 running 32-bit MS Vista Home Premium SP2 box. I use MS auto updates. I think it has onboard shared memory for video and sound. My ISP is Comcast 12mbps with Motorola SURFboard SB5101 Cable Modem direct to...

visual basic
Hi, I trying to retrieve values from a table to calculate the 14days average value of a stock closing price. However, i encounter some problem as stated beside the code as follows: Function DaysAvgs() 'Calculate the average value of a given value. Dim db As DAO.Database Dim rst As DAO.Recordset Dim varBookmark As Variant Dim numAve, numDaysAvg As Double Dim intA, intB, lngCount As Integer Set db = CurrentDb 'Open Table Set rst = db.OpenRecordset("SGX Individual Historical", dbOpenTable) rst.MoveFirst Do While Not rst.EOF intA = 1 intB = 0 varBookmark = rst.Bookmark n...

VBA to creating autotext entries or quickparts in different catego
I have a VBA application that basically allows people to easily create autotext entiries, move them between machines and use them making comments on assignments. Currently it operates in EXACTLY the same way in Word 2003 and 2007 (using userforms) and I want to keep that as long as possible. You can see the application at http://emarking-assistant.baker-evans.com and either the screen image or the video demos will give you an idea of what I am doing Currently I store all the comments in a long list of autotext entries that is displayed in a field with the value of the entr...

Public Folder link to Excel File
Hi - I have a user that claims that he had a shortcut to a spreadsheet "in his public folders" at his old job. Obviously, he's an end user that may or may not know what he's talking about.... I'm trying to figure out the best way to accomodate him. He basically wants an Excel file stored on a shared folder to be available to all user as either a shortcut, or a link in the public folders (can't post to a folder as he will be updating the sheet regularly). When a user clicks on the shortcut/link, it would just launch Excel and display the file. Anybody have any ideas...

Macro for Sharepoint List and another Table?? Same # records?
I am creating a database which we have a form made up of prepopulated data (from a sharepoint list) and also data input needed by a user (for example, comments, etc.). I have two tables: one sharepoint list that is linked to sharepoint website and another table that houses the additional user inputs [table 2]. I have linked the files based on the primary key. So, every record in my table 2 has a plus sign and it will expand and you will see the linked data from the sharepoint list. Is there a way that I can automatically create a record for every corresponding record ...

Receiving Transaction Entry #2
I went into Receiving Transaction Entry to record the receipt of an item. The invoiced price did not agree with the purchase order. I had to add Shipping and adjust the provincial tax. I went to the proper screen to over-ride the calculated tax and the system told me that I couldn't do that because I had not filled in all the BOLD, RED areas. At that point I wanted to close down that screen, but the system would not let me do that either. I could minimize the screen and then I could also see that there wasn't any required information that had not be entered. The only way I c...

Renaming Partial File Names
Is it possible to rename part of a file name? (almost like a find and replace) My database pulls in the excel file names from a directory, with it's subfolders and contents as well. Every file begins with "Kay Form". Kay no longer works in our department, and I'd like to run a loop that replaces "Kay Form" with "Featured Track". I don't know how to do a partial replace though. Thank you in advance! -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access/201001/1 Checkout the Replace function. I...

Opening pub files created with older Publisher versions #2
I have just upgraded to Publisher 2003 from 2000 and am having trouble with pub files sent to me for our chuch newsletter which is using Publisher 97 The text is not wrapping around graphics boxes. Can I fix this? I really don't want to go back to Pub 200 Thank Richard this is caused by Publisher 97 not been printer independent. Even if you went back to Publisher 2000, unless you have the identical font versions and printer driver you would have issues with formatting. It sounds like the person sending you the file has a garbage HP inkjet printer. Get them to install the HP5P laser p...

printing imported gif files in Excel
When printing gif file with transparent background on the grey(25%) background of Excel non-transparent part of the picture has white border around it. Is there any way to prevent it? Thank you in advance... Tim ...

unknown .edb file
I have error messages in the log files that references a corrupt database named C:\Program Files\exchsrvr\Exchangeserver_Outlook.edb. "Outlook" is the name of the server. The problem is that this database is not listed in any of the Mail Stores or Public stores. I want to run the repair utilities on it, but since I'm not sure what it is used for, I don't know how I can restore it if the repair goes bad. Does anyone know what this is used for or how I can determine that myself? BTW, the database always has a current time stamp, so I assume that it is used by something....

Copying dbx files from a CDR back into Outlook
My computer was recently hijakced and I had to reinstall everything. I did however save all of my folders in Outlook onto a CD Rom and I do not know how to transfer them back so I can use them. Also I had an animated version of outlook where you could choose loads of diffent stationery and I cannot seem to find that upgrade anaywhere. Can you help me? Tee <tsahai33@hotmail.com> wrote: > My computer was recently hijakced and I had to reinstall > everything. I did however save all of my folders in > Outlook onto a CD Rom and I do not know how to transfer > them back so...

DB_Backup.MDB file has appeared beside DB.MDB.
I have a local DB.MDB which accesses a DATA.MDB on a network drive. I use a user-level security file. It has been working AOK for a year or so. Yesterday one of the users reported an error dialog when attempting to open the DB.MDB (unfortunately the wording of the dialog was not captured!) After this 'event', the database started working correctly once again. The result was a DB_Backup.MDB file appeared beside the DB.MDB. Any ideas? That backup file is created when ACCESS "crashes" during use..... -- Ken Snell <MS ACCESS MVP> "Andrew (UGL)&quo...

item class table
I am creating SOP IM import. I need to fill the distribution fields with a rev account that is part of the item class. I would like to find a table that would hold the item class accounts. I looked in IV40400 and did not see any distribution accounts. What is the best table to pull these accounts. If the accounts have been defined on the Item Class, they will appear on the records in the IV40400 table. They're in the fields IVIVINDX, IVIVOFIX, etc - and they're just the keys to the actual account definitions in the GL00100 table. If a particular account type isn't defined ...

Archiving Outlook.pst files to Novell Netware file server
Hi all We are trying to perform a manual Outlook inbox archive which we are tryingto save to a Novell file server - but it dowsn't work. Any ideas why? (works fine on the MS2000 server but we don't have the space for everyone) We are currently running Outlook 2003 and the Novell file server is 4.8.3 Any help would be appreciated Thanks!! kwan <kevin.kelly@levittbernstein.co.uk> wrote: > We are trying to perform a manual Outlook inbox archive which we are > tryingto save to a Novell file server - but it dowsn't work. Any ideas > why? (works fine on the MS2000 s...

Sorting by file extension in a worksheet
Hello, I have an excel worksheet which has a list of file names from a directory and various stats about each file. I need to be able to sort them by the file extension. Eg. c:\documents\folderA\picture1.eps c:\documents\folderB\document.doc I would like to sort them by the ".eps" extension. I have tried using the Data,Sort menu and something like *?*.eps as the criteria. But am obvisouly missing something. Any help would be most appreciated. Thanks Karl You could use a helper column to extract just the extension then include this in your sort range and sort on the helper col...

Adding blank "separator" Rows in a Pivot Table
Does anyone know how to insert blank rows into a pivot table (say, between groupings, etc.)? There has to be a way, since some of the various table formats that come with Excel include blank rows. Double-click the field button that you want to format Click Layout Add a checkmark to Insert blank line after each item Click OK, twice Bucko wrote: > Does anyone know how to insert blank rows into a pivot table (say, > between groupings, etc.)? There has to be a way, since some of the > various table formats that come with Excel include blank rows. -- Debra Dalgleish Contextures http...

basic pivot table group
I have looked at some basic Pivot Table tutorials, but I have a very basic question not answered by their examples. . . . I have data in a spreadsheet formatted like this, each row representing an event: Timestamp Process Message ID 11:23:45:123 processA message123 11:23:45:124 processB message123 11:23:45:136 processC message123 11:23:46:123 processA message456 11:23:47:123 processB message456 11:23:47:678 processC message456 Can a pivot table help me reformat the data like below? ...

SOP Sales Transaction Entry Window
Dear Folks, I have noticed that i couldn't choose/select a salesman Id from Sales Transaction Entry Window (Transactions-> Sales -> Sales Transaction Entry). In my case for every Invoice i have to select a Diffierent Sales man ID. Could any one help me how can i enable this. BUT IT IS AVAILABLE IN Transaction Entry Window which we use without inventory module (Transactions-> Sales -> Transaction Entry Window) Awaiting for your favourable feedback. You can find that field by clicking on the customer number expansion button to the right of the customer number field. Thi...