+ Reply to Thread
Results 1 to 7 of 7

Query - How to add a column that uses a formula

  1. #1
    Registered User
    Join Date
    09-21-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    12

    Query - How to add a column that uses a formula

    Hi,

    I am not sure this is possible, but hoping that someone might be able to work out a method!

    I am using a query to pull information from multiple sources and arrange it in a column order suited for a mass import in another program. It is for the calculation of pay for staff members. Is it possible to add a column to the query, which looks at the hours for each employee from the query, then multiplies that by their rate of hourly pay in another tab to give a column for each employee titled "Pay". I would be able to do this for a normal set of data, but im fairly new to queries, so not quite sure if its possible / how to go about it.

    I have attached a version below. However I have had to delete the query as its contains sensitive data, I trust the attachment will still help.

    I hope that makes sense, if not please let me know and I will happily try to explain in another way.
    Last edited by Nickrox; 11-20-2017 at 05:19 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Query - How to add a column that uses a formula

    Is this what you wanted:

    =VLOOKUP(A2,'List of ALL Staff and Pay'!$A$2:$B$9,2,FALSE)*C2

    copied down...
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    09-21-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Query - How to add a column that uses a formula

    HI Glenn,

    Thanks for your advice, that would work for a normal table, but im not sure how to enter it as part of a query?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Query - How to add a column that uses a formula

    Hi

    Maybe the following macro that runs immediately after the Data Query

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    09-21-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Query - How to add a column that uses a formula

    Hi Richard,

    Thanks for your suggestion. I was hoping to be able to use the formula in the query rather than using a macro, but that works! So will use your method! Thanks

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query - How to add a column that uses a formula

    First off - you haven't deleted the query, and all the sensitive data is still there. You may wish to delete the file attachment.

    Second - you can easily add your "Pay Rate" table as a data query, and merge with your existing query.

    Third - you probably want to take the Site / Site Code lookup out of that monstrous "if then else" statement, and put it in a separate table, much like your pay rate table.

    After all that, your query looks something like this (source name removed, to protect your sensitive data):

    Please Login or Register  to view this content.
    Note that you'll need to add queries named tbRates and tbSites which simply look at tables on your "List..." worksheet:

    Please Login or Register  to view this content.
    Last edited by Olly; 11-20-2017 at 05:22 AM.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  7. #7
    Registered User
    Join Date
    09-21-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Query - How to add a column that uses a formula

    HI Olly,

    Thanks for your points on this! Have removed the attachment so thanks for the head up on that one!]

    Will get to work and see how it goes!

    Thanks again!

+ 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. Query column of PC names to retrieve remote mac addresses in another column
    By CME1212 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-13-2016, 04:48 PM
  2. Help with Power Query Custom Column Formula
    By travis.cook21 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-16-2016, 01:45 PM
  3. [SOLVED] Formula - adding an IF Query onto vlookup query
    By mra1984 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-06-2013, 05:31 AM
  4. [SOLVED] Formula Query - COUNTIF? Column A contains word and Column B contains word
    By HelenJH in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-14-2013, 11:23 AM
  5. Replies: 3
    Last Post: 05-22-2013, 01:08 AM
  6. Web Query - Change a word in query to form a new query
    By scottymelloty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2011, 04:13 AM
  7. [SOLVED] Column name in MS Query
    By Revenger in forum Excel General
    Replies: 0
    Last Post: 05-17-2006, 03:20 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