+ Reply to Thread
Results 1 to 13 of 13

Modifying table formula to extract data by price bands

  1. #1
    Forum Contributor
    Join Date
    11-24-2013
    Location
    Huddersfield, England
    MS-Off Ver
    2013
    Posts
    104

    Modifying table formula to extract data by price bands

    Hi All

    I currently break down my horse racing data by Course and also by Month in two separate tables. I am now wanting to duplicate the same table but extract the data by price points as well. I have attached an example and I need help to revise the formula that currently resides in AR108. Previously I have used SUMPRODUCT but not sure how to modify it for a range of prices. I managed to cobble together a formula in AQ108 which counts the number of bets within a price band but I need to calculate what the return is for each price band. If you see what I mean.

    If anyone feels up to it, I could do with the cells AV108, AW108 and AX108 revising as well but that would be an added bonus

    Many Thanks

    Jonathan
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-21-2015
    Location
    Philippines
    MS-Off Ver
    Microsoft Office 2016
    Posts
    146

    Re: Modifying table formula to extract data by price bands

    PHP Code: 
    AQ108=COUNTIFS(K:K,">="&VALUE(TRIM(LEFT(SUBSTITUTE(AP108,"-",REPT(" ",255)),255))),K:K,"<="&VALUE(TRIM(RIGHT(SUBSTITUTE(AP108,"-",REPT(" ",255)),255)))) 
    or
    PHP Code: 
    AQ108=COUNTIFS(K:K,">="&VALUE(TRIM(LEFT(AP108,FIND("-",AP108,1)-1))),K:K,"<="&VALUE(TRIM(RIGHT(AP108,LEN(AP108)-FIND("-",AP108,1))))) 
    Last edited by tamthat; 11-09-2016 at 05:13 AM.

  3. #3
    Forum Contributor
    Join Date
    11-24-2013
    Location
    Huddersfield, England
    MS-Off Ver
    2013
    Posts
    104

    Re: Modifying table formula to extract data by price bands

    Thanks for looking at it for me but I don't think I've explained myself very well

    I need a formula in AS108 (sorry I originally stated AR108) which calculates the return from all the different bets in the price range. Eg, there are 35 bets in the price range 3.00 - 3.99 and I need to calculate how much return I've had from the corresponding data in column P. So I need the formula to add up the returns for all the bets that were in that price range of 3.00 - 3.99. Similar to what the formula in AS92 does.

    Apologies for not being clear

    Jonathan

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,683

    Re: Modifying table formula to extract data by price bands

    Try

    In AS108

    =IF(AQ108=0,"",SUMPRODUCT(--(K$3:K$297>=LEFT(AP108,FIND("-",AP108)-2)+0),(K$3:K$297<=RIGHT(AP108,FIND("-",AP108)-2)+0)--(N$3:N$297=1),--(M$3:M$297)))

    copy down

    Modify other ranges accordingly

  5. #5
    Forum Contributor
    Join Date
    11-24-2013
    Location
    Huddersfield, England
    MS-Off Ver
    2013
    Posts
    104

    Re: Modifying table formula to extract data by price bands

    Hi John

    Thanks for taking the time to have a look. I've used the formula but it's not quite giving me what I need. I've attached the sheet with the filled in formula and the numbers can't be right. I think the formula needs to use the values in column P to calculate how much each price band returns.

    Thanks again

    Jonathan
    Attached Files Attached Files

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Modifying table formula to extract data by price bands

    Perhaps this for AS108

    =IF(AQ108=0,"",SUMIFS(P$3:P$297,K$3:K$297,">="&LEFT(AP108,FIND("-",AP108)-2),K$3:K$297,"<="&RIGHT(AP108,FIND("-",AP108)-2),N$3:N$297,1))

    It could be greatly simplified if you were to use a start and end column for your bands- e.g. 3 in one column, 3.99 in the other.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,683

    Re: Modifying table formula to extract data by price bands

    Change M to P

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Modifying table formula to extract data by price bands

    Is there not also a missing comma

    =IF(AQ108=0,"",SUMPRODUCT(--(K$3:K$297>=LEFT(AP108,FIND("-",AP108)-2)+0),(K$3:K$297<=RIGHT(AP108,FIND("-",AP108)-2)+0),--(N$3:N$297=1),--(P$3:P$297)))

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,683

    Re: Modifying table formula to extract data by price bands

    Well spotted!

  10. #10
    Forum Contributor
    Join Date
    11-24-2013
    Location
    Huddersfield, England
    MS-Off Ver
    2013
    Posts
    104

    Re: Modifying table formula to extract data by price bands

    Hi Guys

    I've used your formula xlnitwit and we seem to be on the right track but not quite there. It returns a value but the totals don't add up so there's a problem somewhere.

    I've attached the same sheet with the formula in AS108 included and if you look in column x those are the return values the cells in AS108:AS129 should be returning.

    The total value in cell AS130 should match those in cells AS88 and AS104.

    All help gratefully received.

    Jonathan
    Attached Files Attached Files

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Modifying table formula to extract data by price bands

    Why should they match? You stated that the formula should return the values from column P but the formulas above return values from column M, so which one is correct?

  12. #12
    Forum Contributor
    Join Date
    11-24-2013
    Location
    Huddersfield, England
    MS-Off Ver
    2013
    Posts
    104

    Re: Modifying table formula to extract data by price bands

    Ah, I see what I've done there. Thanks for pointing it out to me. I've changed the formula to read column M instead of P and voila. Perfect!

    Many thanks for your help

    Jonathan

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Modifying table formula to extract data by price bands

    You're welcome.

+ 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. Price Per Unit in a Table for a Fixed Incremental Price Discount
    By natkoy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-22-2016, 03:51 AM
  2. I want to extract Now price and was price in separate column? please help
    By nvn.r10 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-13-2015, 12:55 PM
  3. how do i get the most popular bands using a pivot table
    By MysJee in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 11-18-2014, 06:25 PM
  4. Replies: 2
    Last Post: 05-05-2014, 04:37 AM
  5. Modifying Code to Extract All Data From Word Documents
    By Logitron in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2013, 07:16 PM
  6. Need help with modifying the VBA code Extract data
    By honeybunny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2013, 09:10 PM
  7. Help Needed: Working Out Price Bands..?
    By NJ106 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-08-2007, 09:07 AM

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