+ Reply to Thread
Results 1 to 9 of 9

Dynamic criteria for SUMIF or dynamic getpivotdata

  1. #1
    Registered User
    Join Date
    06-15-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    23

    Lightbulb Dynamic criteria for SUMIF or dynamic getpivotdata

    Hi Everyone,

    I need help with a spreasheet issue related to my trading strategy.

    It would be great if I could upload the excel file, but it is too large. So I will carefully explain the problem with several images labelled in 2 word documents.


    Image 1 Shows - The week# and closed pips (for the specified week #) [as shown by 83.6, 25.3, 32.3 etc]

    If we zoom into the formula for closed pips, we see that it contains a complex getpivotdata formula (Image 2)
    The pivot table is hidden. If I unhide the pivot table, we get image 3

    We can zoom into where the data comes from as shown in images 4 and 5.
    Image 4 shows - Trade week (rank)
    Image 5 shows - Total PnL


    My problem:
    I need the "Closed Pips" as shown in image 1 to be dynamic. For example, if I filter out some data in my spreadsheet, the closed pips returned in a week should change. But it does not. At the moment, I would have to manually filter the data in the hidden pivot table.

    What I have done so far:
    I have created a SUMIF formula as shown in image 6. This formula needs to be improved on. Ideally, the criteria "=1" should be dymamic. As it represents the week.

    If we look at image 7 - you can see we get the same -83.6 as we get at the top of closed pips in image 1. However, as the criteria is not dynamic, we fail to get 25.3 below as a representation of the closed pips in week 2. Instead we get 78.3.


    What I'd like help with:
    1. Either fixing this formula, so I can replace the complex getpivotdata formula shown in image 1

    OR

    2. Some how make the complex getpivotdata dynamic so that as I filter things throughout my spreadsheet, the closed pips reflects the change.


    Thank you
    Attached Files Attached Files
    Last edited by Mikes_KM; 07-21-2019 at 12:54 PM.

  2. #2
    Banned User!
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    To base a formula result of filtered data you would need to use either AGGREGATE or SUBTOTAL.

    Without trying to cross refernce a load of pictures with descriptions, from your description, I would suggest duplicating the column to sum using =SUBTOTAL(9,A2) where A2 refers to a cell with the data to sum, filled down, then summing that column with SUMIF.

    For week number "=1", you can enter the criteria in a cell, then change that, you don't need the "=" part, just the week number in a cell. Making it dynamic based on current date would make all of your formulas volatile, which would mean calculation lag with every change to the data.

  3. #3
    Registered User
    Join Date
    06-15-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Hey Jason, thanks for your response. I am, going to give it a go.
    FYI, I am going I have created a shareable link https://drive.google.com/file/d/1i3C...ew?usp=sharing

    It may be best to download and open it with microsoft excel as google sheets abilities seem limited

  4. #4
    Registered User
    Join Date
    06-15-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    I have come close. What I did was fix the beginning of the range and use this formula - =SUMIF([Trade week (Rank)],1,$T$13:T359)

    Now one issue remains: I would like to copy this formula down. The criteria "1" needs to increase eg. =SUMIF([Trade week (Rank)],2,$T$13:T359) , SUMIF([Trade week (Rank)],3,$T$13:T359) etc

    Thanks

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    41,986

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  6. #6
    Registered User
    Join Date
    06-15-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Here is the link to the other forum, https://www.mrexcel.com/forum/excel-...ml#post5312807

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    41,986

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Thank you.

  8. #8
    Banned User!
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Try using the ROWS() function for the criteria for copying down, or COLUMNS() for copying right to left.

    =SUMIF([Trade week (Rank)],ROWS(X$2:X2),$T$13:T359)

    The cell reference would ideally be the cell that holds the first formula, so in the above example the formula would be in X2. If using the COLUMNS function to copy right, then the range would be $X2:X2, absolute column instead of row. (Absolute row / column = locked, relative = unlocked).

    Also, we prefer that you attach samples to the forum in workbooks rather than posting images, or links to external sites. We don't need all of the data, usually a trimmed down copy with 10-20 rows is sufficent to demonstrate the requirement.
    Last edited by jason.b75; 07-21-2019 at 11:57 AM.

  9. #9
    Registered User
    Join Date
    06-15-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Dynamic criteria for SUMIF or dynamic getpivotdata

    Hi Jason, thanks that solved my problem!!! It has lead to my graphs not responding to the new formula, but I will probably be able to figure that out soon.

    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. Dynamic sumif based on changing list of inclusion criteria?
    By Oppo28 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2017, 04:28 PM
  2. [SOLVED] SUMIF criteria across dynamic range
    By Journeyman3000 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2014, 05:10 PM
  3. Dynamic Criteria for SUMIF, multiple selections
    By alhimyaa in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-18-2013, 01:30 AM
  4. Dynamic sumif ranges based on Hlookup criteria
    By Dial1 in forum Excel General
    Replies: 2
    Last Post: 10-24-2011, 01:21 AM
  5. SUMIF with Dynamic Criteria
    By nofzinger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2010, 06:17 PM
  6. SUMIF with dynamic criteria
    By inky in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-08-2008, 08:59 AM
  7. Sumif using dynamic date criteria
    By bkube01 in forum Excel General
    Replies: 3
    Last Post: 08-25-2006, 11:11 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