Assignment of a value to a entry in a big dataset

peperosso

New Member
Joined
Oct 13, 2015
Messages
8
Hi everyone!

I have a sheet with thousand of records and I have to run a specific function on one of the columns. The latter contains a large number of duplicates. I set up a new function with VB, but I cannot run it on all the data due to the required computational effort. Therefore I thought to create a new column without replicates, and to run the function on this new column.

However, I do not have a clue on how I can assign the new values (obtained running the function on the new column) to the entries of the original table. I thought to do that with a series of nested IF, but it would be simply impossible due to the high amount of data.

Here a simple table to exemplify my problem:

KeyCity (with replicates)Preferred food of the citizensCity (without replicates)Preferred food of the citizens
1ChicagoChicagoHamburger
2LondraNew YorkPizza
3RomaRomaPasta
4LondraLondraFish&Chips
5Roma
6Roma
7New York
8Londra
9Chicago

<tbody>
</tbody>

As you can see in the table, I have a list of rows (identified by a keys), each of which has an attribute "city". Suppose that with my VB function I am able to calculate the preferred food of the inhabitants given the name of the city. The function is quite expensive and I cannot run it over all my entries: therefore I create a new column without replicates, and I run the function on this new set. Then I have to re-assign the outcome of the functions to my initial set of rows...
Any suggestion on how I should do?

Thank you in advance for your time!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi everyone!

I have a sheet with thousand of records and I have to run a specific function on one of the columns. The latter contains a large number of duplicates. I set up a new function with VB, but I cannot run it on all the data due to the required computational effort. Therefore I thought to create a new column without replicates, and to run the function on this new column.

However, I do not have a clue on how I can assign the new values (obtained running the function on the new column) to the entries of the original table. I thought to do that with a series of nested IF, but it would be simply impossible due to the high amount of data.

Here a simple table to exemplify my problem:

KeyCity (with replicates)Preferred food of the citizensCity (without replicates)Preferred food of the citizens
1ChicagoChicagoHamburger
2LondraNew YorkPizza
3RomaRomaPasta
4LondraLondraFish&Chips
5Roma
6Roma
7New York
8Londra
9Chicago

<tbody>
</tbody>

As you can see in the table, I have a list of rows (identified by a keys), each of which has an attribute "city". Suppose that with my VB function I am able to calculate the preferred food of the inhabitants given the name of the city. The function is quite expensive and I cannot run it over all my entries: therefore I create a new column without replicates, and I run the function on this new set. Then I have to re-assign the outcome of the functions to my initial set of rows...
Any suggestion on how I should do?

Thank you in advance for your time!
Hi peperosso, welcome to the boards.

Based on your example above, once you have the shortened list without duplicates, you can do a VLOOKUP in your original table. I used the following formula to produce the results shown below:

=VLOOKUP(B2,$E$2:$F$5,2,FALSE)

Bold green B2 is the lookup value (city)
Bold red $E$2:$F$5 is the table it is looking up from (the table without duplicates)
Bold blue 2 is the column in the lookup table you want to get the result from (preferred food of the citizens)
​Bold orange False tells the VLOOKUP you want an exact match

Excel 2010
ABCDEF
1KeyCity (with replicates)Preferred food of the citizensCity (without replicates)Preferred food of the citizens
21Chicago =VLOOKUP(B2,$E$2:$F$5,2,FALSE)ChicagoHamburger
32LondraFish&ChipsNew YorkPizza
43RomaPastaRomaPasta
54LondraFish&ChipsLondraFish&Chips
65RomaPasta
76RomaPasta
87New YorkPizza
98LondraFish&Chips
109ChicagoHamburger

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



In the screenshot above I added a space before the formula in the first cell to make it show the actual formula rather than the result. The cells below that have the correct formula without the preceding space.

I hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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