# Dynamic criteria for SUMIF or dynamic getpivotdata

1. ## 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

2. ## 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. ## Re: Dynamic criteria for SUMIF or dynamic getpivotdata

Hey Jason, thanks for your response. I am, going to give it a go.

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

4. ## 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. ## Re: Dynamic criteria for SUMIF or dynamic getpivotdata

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.)

6. ## Re: Dynamic criteria for SUMIF or dynamic getpivotdata

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

Thank you.

8. ## 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.

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.

9. ## 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 !!!

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### 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