+ Reply to Thread
Results 1 to 15 of 15

Calculate a value based on several conditions, dont think "if" function works

  1. #1
    Registered User
    Join Date
    07-31-2023
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    4

    Calculate a value based on several conditions, dont think "if" function works

    I have a table with information of several stores. The first column is the store name, the 2nd column is the identification of the micro market where the store is located, the 3rd column is the quality of the store (very good, good, medium or poor) and final column tells me the value of the micro market by store. I need to calculate the value of each micro market with a condition regarding the store quality.

    Example:

    I have a micro market with 6 stores. 2 good, 2 medium and 2 poor. This micro market is worth 100. If i split it evenly each store is supposed to be worth 100/6= 16.(6). But if i have in consideration the store quality it should be something like: For the good stores i multiply it with 1.2, for the medium for 1 and for the poor for 0.8. So the good stores would be worth 16.(6)*1.2=20, the medium 16.(6)*1, and the poor 16.(6)*0.8=13.(3)

    my problem is that each mirco market has a different number of stores and each with different qualities. How can i have a solution that will allow me to do these computations "automatically"?


    Thank you in advance
    Last edited by Franciscofig; 08-01-2023 at 04:34 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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    Hi there.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 non-editable pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet complete with an explanation and some expected results.
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Calculate a value based on several conditions, dont think "if" function works

    You could have a small table somewhere on your sheet for the quality and weighting factor, like this:

    Good ........ 1.2
    Medium .... 1
    Poor ......... 0.8

    then you could use a VLOOKUP function to get the appropriate factor.

    It would help if you attached a sample Excel workbook, by following the guidelines given in the yellow banner at the top of the screen.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    07-31-2023
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Calculate a value based on several conditions, dont think "if" function works

    Sorry guys, i'm new here! This is an example of a the sheet i'm working on.

    Thank you again
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,852

    Re: Calculate a value based on several conditions, dont think "if" function works

    Is this what you want?

    =E2*LOOKUP(C2,{"GOOD","MEDIUM","POOR"},{1.2,1,0.8})

    =E2*PROC(C2;{"GOOD";"MEDIUM";"POOR"};{1,2;1;0,8})
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    What's the factor for "Very Good"?

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Calculate a value based on several conditions, dont think "if" function works

    If you have your table of quality and Factor in cell H2:I5 (to allow for a Very Good entry), then you can use this formula in F2:

    =E2*VLOOKUP(C2,$H$2:$I$5,2,0)

    Copy down as required.

    Note that you could use COUNTIF in column E rather than hard-code the number of stores, i.e. in E2:

    =D2/COUNTIF(B:B,B2)

    Hope this helps.

    Pete

  8. #8
    Registered User
    Join Date
    07-31-2023
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Calculate a value based on several conditions, dont think "if" function works

    That's my problem exactly. The factors will change based on the different stores present. Because if i have a micromarket with a Good a Medium and a Poor. For that scenario the factors are 1.25, 1 and .75 respectively. But in a scenario with a Very Good, a Good, a Medium and Poor the factors would be 1.5, 1.25, .75 and .5 respectively. In a scenario with only Medium and Poor the factors should be like 1.10 for Medium and 0.90 for Poor.

    Sorry for the mess don't know if i'm explaining it well..

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Calculate a value based on several conditions, dont think "if" function works

    There are a number of different combinations that you could "theoretically" have, e.g. Good and Poor stores only, or Very Good with Medium, and so on. Also, does the number of stores of each type affect the factors for a particular market, e.g. if you have a market with 1 Good, 5 Medium and 1 Poor (7 in total), would the factors be the same for a market with 3 Good, 1 Medium and 3 Poor?

    You need to explain your variables more clearly.

    Pete

  10. #10
    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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    Oh ****. I had it working perfectly until you complicated EVERYTHING with that last post.

    Post a file showing the factors for ALL possible scenarios. No more guessing, please!!

  11. #11
    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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    In case the OP doesn't reply for a while and I've gone away... this is where I'd got to:

    =MAP(B2:B17,C2:C17,D2:D17,LAMBDA(x,y,z,(VLOOKUP(y,$H$2:$I$4,2,FALSE)*z)/SUMPRODUCT(--($B$2:$B$17=x)*VLOOKUP($C$2:$C$17,$H$2:$I$4,2,FALSE))))
    Attached Files Attached Files

  12. #12
    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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    I guess that there may be 4! combinations = 4x3x2x1 = 24 separate combinations of VG,G, M & P. I had thought of using something like this, but if there was a case of 2 categories in a store: VG and P, a division of 1.1 and 0.9 is (probably) too simple... We need a SPECIFIC requirement set out.
    Attached Images Attached Images

  13. #13
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Calculate a value based on several conditions, dont think "if" function works

    Using V for Very good, G for Good, and so on, you can have these variations of stores making up the micro markets:

    V G M P
    V M P
    V G P
    V G M
    G M P
    V G
    V M
    V P
    G M
    G P
    M P
    V
    P
    M
    G

    Of course, some of these may not exist, e.g. those with only a single type.

    Instead of the simple two-column table that I suggested earlier, you could now compose a table with these market types in the first column, then 4 other columns for the Quality, and then record the factors in the appropriate column for each market type. Then a modified VLOOKUP (or INDEX/MATCH) formula could get you the appropriate factor, assuming you can classify the Market type as one of the above.

    Hope this helps.

    Pete

  14. #14
    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,053

    Re: Calculate a value based on several conditions, dont think "if" function works

    This has been going round in my head for some time now. I now suspect you're overcomplicating things. I return to my original formula (adapted to include Very Good).

    In my opinion, any combination of VG, G, M & P (that I've looked at) seems reasonably fair, in terms of the final outcome.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    07-31-2023
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Calculate a value based on several conditions, dont think "if" function works

    I guess this is the best way to simplify things. Maybe i was over complicating with the several different scenarios and the different factors for each scenario. This seems to me to be the best solution for the problem. Thank you very much

+ 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. [SOLVED] Code works with OnChange but not with Worksheets("Name").Calculate
    By BRISBANEBOB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 05:10 PM
  2. [SOLVED] Code works in the macro but not in a separate function. "Sub or function not defined."
    By tahi.laci in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-28-2014, 12:38 PM
  3. Match function works while the "=" says True! Driving me crazy!
    By tony.nz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2014, 02:17 PM
  4. [SOLVED] Pasting values between ranges in different workbooks: "Range" works but "Cells" doesn't
    By Flaubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2013, 01:19 PM
  5. Open files from FTP server (works with "servername" but doesn't work with "ip address")
    By adammsu1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2012, 04:30 PM
  6. Defining logic "Yes" or "No" , based on multiple conditions
    By pyol17 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 02:41 AM
  7. Replies: 7
    Last Post: 05-13-2006, 05:02 PM

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