+ Reply to Thread
Results 1 to 15 of 15

get values from a table and calculate in another

  1. #1
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    get values from a table and calculate in another

    I have a table, stored data of foods and prices (product description table)
    I have another table. it has product name and quantity bought. I need to create a column for expense. (price of the product from product description table * quantity from expense table)

    can I do that? I am using excel 2013. an example is attached herewith.

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: get values from a table and calculate in another

    Maybe this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    04-27-2015
    Location
    Abu Dhabi, U.A.E
    MS-Off Ver
    Office 365 | 2016
    Posts
    696

    Re: get values from a table and calculate in another

    Use this formula in M16

    =L16*INDEX($F$9:$F$14,MATCH(K16,$E$9:$E$14,0))
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: get values from a table and calculate in another

    @Shareez Saleem: when the OP has all those Structured Tables, it seems a shame not to use Structured Table references

  5. #5
    Valued Forum Contributor
    Join Date
    04-27-2015
    Location
    Abu Dhabi, U.A.E
    MS-Off Ver
    Office 365 | 2016
    Posts
    696

    Re: get values from a table and calculate in another

    Let him understand it in a simple way.


  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: get values from a table and calculate in another

    Select the table with Product Price and Category then click on the Formulas tab, Defined Names, Create from Selection. Choose Top Row and Left column. This will give you names for all of the products and the price of each.

    In M16 enter this formula and fill down the column of the table.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will use the product in K16 (which is a defined name from the above procedure). The INDIRECT function makes the value in K16 a value to be recognized as a name. There is a space between the INDIRECT(K16) and Price. This creates and intersection in the table that has a value. This value is then multiplied by the value in [@Quantity]. This results in a formula that is Product Price, times Quantity.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: get values from a table and calculate in another

    Thanks all. newdoverman you are great.

  8. #8
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: get values from a table and calculate in another

    Quote Originally Posted by newdoverman View Post
    Select the table with Product Price and Category then click on the Formulas tab, Defined Names, Create from Selection. Choose Top Row and Left column. This will give you names for all of the products and the price of each.

    In M16 enter this formula and fill down the column of the table.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will use the product in K16 (which is a defined name from the above procedure). The INDIRECT function makes the value in K16 a value to be recognized as a name. There is a space between the INDIRECT(K16) and Price. This creates and intersection in the table that has a value. This value is then multiplied by the value in [@Quantity]. This results in a formula that is Product Price, times Quantity.
    This is the nicest mtd I have seen so far. However in the pivot table I can't use expense as a number column. If you can fix this, would be a great help.

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: get values from a table and calculate in another

    Your pivot table must have been created in Excel 2013 as I cannot reproduce it in Excel 2010. I however did produce a Pivot table that did include the expense column and it worked perfectly. I can see no reason that it won't work for you. You may have to rebuild the pivot table to get it to work or refresh the Data Sources as there are more than one.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: get values from a table and calculate in another

    Not sure what you are trying to do ... but this updated sample workbook has a Pivot Table created in Excel 2007.

    Regards, TMS
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: get values from a table and calculate in another

    Thanks. but your pivot table has only one data table in it. I need all three tables.
    Let's say I need to get expenses by gender. Problem with the formula is it gives expense as text values when made the relationship. Pls see the image.
    Capture.JPG

  12. #12
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: get values from a table and calculate in another

    Quote Originally Posted by newdoverman View Post
    Your pivot table must have been created in Excel 2013 as I cannot reproduce it in Excel 2010. I however did produce a Pivot table that did include the expense column and it worked perfectly. I can see no reason that it won't work for you. You may have to rebuild the pivot table to get it to work or refresh the Data Sources as there are more than one.
    as far as I am using a pivot table for one data table, everything OK. but the idea of this whole work is building relationships among different tables and make a data model.

    for an example I need to divide expenses by gender. (in pivot table gender in raws, expense in values) can you do that? mine is giving an error...

    Thanks.

  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: get values from a table and calculate in another

    In order to do what I think you want with the Pivot table using Excel 2010, I had to incorporate columns from the other tables into the main table. I added the columns in the main table then by formula extracted the data from the other tables.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: get values from a table and calculate in another

    Quote Originally Posted by newdoverman View Post
    In order to do what I think you want with the Pivot table using Excel 2010, I had to incorporate columns from the other tables into the main table. I added the columns in the main table then by formula extracted the data from the other tables.
    ha ha ha .... objective of the study is to avoid this. so we DO NOT need to store all the unnecessary data (repeatedly) in one big table. instead we can store nice and neat separate tables for people, food and expenses AND analyze data using any variable from any table as the need be.

    Thanks anyway. Appreciate your time and effort.

    P.S and your named range thing did work. so as far as expenses is number column, (not a calculated column ) I can do pivoting with all three tables.
    Last edited by Dineth; 08-27-2015 at 11:40 PM.

  15. #15
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: get values from a table and calculate in another

    Well what you have in your workbook is produced in Excel 2013 and the same thing isn't available in Excel 2010 so cannot be produced in the same manner. Someone with Excel 2013 might be able to help you out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populate & Calculate Values in Main Sheet from Table
    By EcoMike in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-18-2015, 06:08 PM
  2. Replies: 5
    Last Post: 01-24-2014, 04:53 AM
  3. How to calculate percentage change between values in a pivot table
    By no.18shirt in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-03-2013, 01:48 PM
  4. Calculate Table Values using a PivotTable
    By theshaun in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 02-26-2013, 09:01 AM
  5. Calculate cost and mark up based on table of values
    By adam.priest in forum Excel General
    Replies: 1
    Last Post: 05-17-2012, 12:04 PM
  6. Replies: 12
    Last Post: 02-06-2012, 11:23 AM
  7. [SOLVED] automatically calculate table values via formulas in sheet
    By Montfrooij in forum Excel General
    Replies: 2
    Last Post: 01-24-2006, 04:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1