+ Reply to Thread
Results 1 to 11 of 11

Running Multiple calculations per record per table across 2 tables

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Running Multiple calculations per record per table across 2 tables

    Hi, I am a VBA programmer and unfortunately have a task that requires the use of only formulas, i have a very basic knowledge of array formulas and using lookups and i think that what i need to achieve is going to require something alot more complex than a lookup or 2, im not even sure whether its possible using formulas alone, i will try and explain this as best as i can.....

    I have 2 sheets that a user will copy paste data into, sheet one will hold some inventory stocks with prices, descriptions, and some other related data, on sheet 2 there will be a table that holds information relating to banks, a single bank may have several records listed here and each record will have criteria and loan information that i need to compare to the stocks data. the problem im getting is each record in the stock sheet needs to be compared to each record in the banks sheet and i then need to find the best option within the banks sheet and then display all the calculated data on yet another sheet which should have all the stocks (still debating whether or not to list items not meeting the criteria requirements) and then also shows all the calculations of the best pick from the banks data.....

    all the googling and youtube videos are great but it seems i need something that will perform a lookup multiple times on the banks sheet per item on the stocks sheet and nothing ive seen seems to go this far..... is this even possible and if it is is there a term or name for this i can use to google how to do it, or even better some example formula that will do this that i can try and adjust.....


    ill try and give a quick example to try and make it easier to follow

    table1......Stock
    |Name|Cost|Year
    |Item1|200|2010
    |Item2|300|2015


    table2.....Banks
    |BankName|Service Level|Min Loan Amount|Interest Rate
    |Bank1|SL 1|200|0.04
    |Bank1|SL 2|300|0.03
    |Bank2|SL 1|250|0.03


    table3..... Calculated Data
    this table is going to hold the items followed by the best bank selected by performing several calculations on each one per stock item.....


    please just let me know if more information is needed

    Thanks
    Paul S

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Running Multiple calculations per record per table across 2 tables

    Hi Paul and welcome to the forum.

    I'm pretty sure I know you from another board where you have helped me more than once.

    It would probably be better if you could upload a workbook here.

    You can click on go advanced and use the paperclip icon.
    ViewPic

  3. #3
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: Running Multiple calculations per record per table across 2 tables

    Hi, you may have seen me on another site (not sure if i can post it here) its a vb site that i used to use alot, hopefully you can help me out though .

    this has actual data that i need to use, i left a couple of notes on an empty sheet....

    example.xls

    Thanks
    Paul S.

  4. #4
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Running Multiple calculations per record per table across 2 tables

    Paul,

    I think this may be possible but I'm no expert on formulas. What do you mean: "the calculations are just pmt etc. etc."?

    In any case, I can propose a very simple solution that can be carried out with simple linear methods below. I described it exhaustively, but I want to make sure I understand the problem and how to simplify it moving forward: Y = P*Q*X. More on that later. As a worst-case scenario, what I understand your problem to be can be solved by hiding a few intermediate calculations somewhere in the workbook, but I expect it can be done in one line with a clever use of Array-entered formulas or something like that (never worked with "A.-e.'d formulas" before so I could be wrong about the one-line thing).

    Working at this piece-wise, I can build expressions of individual conditions such as (note: the following formulas are written in the Inventory Worksheet for testing purposes):

    Qualitative description of Matrix Q (described below) for one row/column, depending on how we define our indicies:
    {
    Category_________||Specific Example (which can be generalized)_____________________________||=Formula
    Max Miles Condition||E2 must be less than Rates mileage condition_____________________________||=Rates!G2>E2
    Min Year Condition || Extracted Year from B2 must be equal to or greater than year specified by Rates||=Rates!C2<=INT(LEFT(B2,4))
    .
    .
    .
    Category W_______||Specific example W -- for clarification purposes___________________________||=FormulaW
    }
    ...and then look at several different rows in the rates.

    I can explicitly find the conditions for all "W" conditions.

    What are your thoughts of building the individual expressions and then testing the entire inventory for each of the regions? That would involve an intermediate operator (matrix) of dimension NXM of Boolean values based on W conditions, where (again) W is the number of conditions, N is the number of cars in the inventory, and M is the number of bank regions. With an AND(Condition1, Condition2, ... , ConditionW) statement, you can determine whether or not you perform a calculation in order to find the optimal bank/region.

    With Y = P*Q*X, Y is a 1xN vector of the best banks (your results/output), X is an 1xN vector of inventory (input), P is an NxM matrix (the math you do to figure out which bank region gives you an the best rate, without considering logical conditions) -- don't worry about the fact it's a matrix instead of formulas... that will become clear later, and Q is an MxN matrix of logical conditions as described above (without considering the best rate).

    Does that sound like the direction in which you'd like to proceed or am I missing something?

    Joe
    Last edited by joe31623; 01-09-2016 at 03:01 AM.
    <---If my answer helped, please click *

  5. #5
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: Running Multiple calculations per record per table across 2 tables

    Hi

    I need 2 versions of this, each one using a different calculation..... lets not go with the pmt one for now and stick with the following....

    Cost - ((((Cost * Adv) - TitleFee)/(1+Tax)) - DocFee)

    Cost is located on the stock sheet
    Adv is located on the bank sheet
    TitleFee is 16.50
    Tax = 3.25%
    DocFee = 899

    this calculation should give the gross income minus the original cost, this is what i need to rank and return the highest/best one for each stock/car....

    this all needs to be dynamic as well, some user will just copy paste (replacing the old tables) some data and all this stuff needs to happen without any other interaction.


    I'm really struggling to get my head around how to do that using formulas :D.......

  6. #6
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Running Multiple calculations per record per table across 2 tables

    ...Assuming that ADV is located in cell: AB2 in the Rates Worksheet, your formula, as I understand it:

    Cost - ((((Cost * Adv) - TitleFee)/(1+Tax)) - DocFee) is =Inventory!V2-((Inventory!V2*Rates!AB2-16.5)/(1+0.0325)-899)

    Let me know if adjustments to the formula above are required.

    I understand you want to generalize this, but before I can help with that, I need to understand ADV. If there was one column of ADV values or a 1:1 correspondence between Inventory and ADV values, it would be simple but I don't see any such apparent relationship (but I'm sure there is). Perhaps is there just one ADV value omitted on the rates worksheet and there should be 6 instead of 5 b/c there are 6 vehicles in the inventory?
    Last edited by joe31623; 01-09-2016 at 03:38 AM.

  7. #7
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Running Multiple calculations per record per table across 2 tables

    Now... would you like to work on determining the best bank for the inventory you have with a simple Y = AX-style solution? That way, a user can put in any number of vehicles in the inventory, any number of banks in the inventory, and an output will display the best bank to use per vehicle without thinking about it.
    Last edited by joe31623; 01-09-2016 at 03:42 AM.

  8. #8
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Running Multiple calculations per record per table across 2 tables

    First, let me answer your immediate question once I know: "Which ADV?" I see 1 ADV, 2 ADV, 3ADV, ..., 5ADV.

    As far as the formulas, don't worry about it. If we work on one simple case, we can generalize the solution if we simply hide a few values in the spreadsheet somewhere. It really is as simple as Y = A*X, with a clever choice of A!

    I'll even venture to say that anything can be described by Y = A*X, with a clever choice of A.

  9. #9
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: Running Multiple calculations per record per table across 2 tables

    Hi, thanks for all the input, to answer your last question, yes im hoping to have a simple table of answers with a couple of columns from the vehicles table and then some the name of the bank and maybe the tier/deal description and then the actual calculations, i think thats the main goal..... however if its possible to create a table of every possible results and then have another formula use that to get the table i describe above thats great, at least the user can see all the results if need be.....

    As for how this is done, im really in over my head with this matrix and may need to do some studying, but it sounds like you have a grasp on what needs to be done

    The bank table by the way i will adjust, its not format in a friendly way at the moment and the rates and ADV i want to place on there own row for example.......

    |Bank|Region|Other Columns...|Rate 1|ADV 1|
    |Bank|Region|Other Columns...|Rate 2|ADV 2|
    |Bank|Region|Other Columns...|Rate 3|ADV 3|

    otherwise its going to be very difficult to break this section down for each bank as their ranges/dimensions will differ

    but it sounds promising what you are proposing and ill do whatever i can .....

    Thanks
    Paul S.

  10. #10
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Running Multiple calculations per record per table across 2 tables

    Paul,

    Ok. Sounds like you've got some work to do before we move forward. I'll send you a private message with my e-mail because this one links up to one I seldom check unless I happen to be on here. Feel free to message me on here or my e-mail and I'll see if I am available/able to help.

    Joe

    PS I don't recommend confusing yourself with thinking about matricies but I'll break it down for a simple [2x1 element] = [2x1 element]*[1x1 element] case

    Let's say we have 1 car that costs $20,000
    We have to pay two taxes: State tax(3%) and Federal taxes(7%) on the purchases in the USA but...
    We have to pay two taxes: Local Tax(1%) and Government taxes(8%) on the purchase in Mexico...
    Let Y = A*X, where Y is taxes paid, X is price of the car, and A is a matrix of tax rates -- let's say in the USA.

    Now you can easily figure out w/o thinking about matrices that you pay in taxes: $20,000*.07+$20,000*.03 in the US and a similar expression for Mexico.

    All a matrix does is simplify and generalize things. so you can write: Y = A*X instead of $20,000*.07+$20,000*.03. You can also think of it like a table -- that's all a matrix really is. But if you never worried about matrices before, I wouldn't start now. All I need to know is the $20,000*.07+$20,000*.03 part of the problem.
    Last edited by joe31623; 01-09-2016 at 04:26 AM.

  11. #11
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: Running Multiple calculations per record per table across 2 tables

    just to clarify on ADV and Rates, the table is laid out so that each particular offer/package are going down the rows, right at the end of this portion of the table there is 2 more sections (Rate and ADV), and just below these there are a set of ranges (), these i think are like credit ratings and depending on this rating depends on which Rate and ADV applies, like i mentioned in the last post i will rearrange this table slightly and duplicate the rows to allow these ranges, Rating and ADV to each have their own row so the lookup is straight forward........Hope this explains it a little better.


    Originally this rating/credit rating value was going to be a variable that the user chooses but its now been decided to work out all of these rating, this is going to increase the amount of calculation alot but will give the data needed to target and match buyers, to pbank plans with certain gains or losses (not sure about the internal thinking behind this, all i know is they need a couple of variations with the calculations) and they at least want to see the best option, and if possible the whole list of options and their ranks
    Last edited by gbeats101; 01-09-2016 at 04:30 AM. Reason: extra details

+ 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. best way to record multiple variables before use in pivot table
    By masterintraining in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-14-2012, 03:02 PM
  2. VBA Pivot Table - Multiple Tables - Multiple Sources of Data
    By ryanmorris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 03:13 PM
  3. Replies: 1
    Last Post: 01-17-2012, 10:47 AM
  4. Multiple table calculations & referencing
    By Miglia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2009, 07:25 PM
  5. Multiple calculations in Pivot Table
    By amirs318 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-05-2008, 11:15 AM
  6. [SOLVED] Dealing with a large table and multiple calculations
    By scrabtree23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2005, 11:06 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