Adjusting GETPIVOTDATA Formula To Be Dynamic

ExcelAtEverything

Active Member
Joined
Jan 30, 2021
Messages
351
Office Version
  1. 2019
Platform
  1. Windows
I am on the Year To Date (YTD tab now, and stuck on the same thing When I grab the static formula for the Pivot Table position, I need to adjust the Org # portion so the formula can be pulled downward and will translate properly to the diffferent Org #'s, and same holds true for date needing to be able to be pulled to right, as well as account for the fact that next year will be a new year. I'm trying very hard, but I'm having a tough time trying to grasp certain aspects of the GETPIVOTDATA function. Any help here greatly appreciated as always.

Green/White table w/ blacked out names: this table (named "YTD_GS") is the main sheet where the GETPIVOTDATA formulas go. Sheet name is "Main".
Black/white Pivot Table:

If I just grab the static Power Pivot data cell, the formula looks like this: =GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'YTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&[237]","[Monthly Orders Reports].[Date (Year)]","[Monthly Orders Reports].[Date (Year)].&[2021]")
And it fills down incorrectly like this.
1617511134110.png

.
1617511387388.png

I tried editing it myself and came up with this, which seems right to me, but it only throws #REF errors.
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'YTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&["&[@[Org '#]]&"]","[Monthly Orders Reports].[Date (Year)]","[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1,"mmm")&"]")

Thanks!
 
Whoa! That worked great!???

Doing your first ever GetPivot formula using the Data Model & Power Pivot was certainly throwing yourself in the deep end.
Even if Mynda Treacy from MyOnlineTrainingHub says:-
"Don’t despair because writing relative Power Pivot GETPIVOTDATA formulas is easy.
All we need to do is replace the hard-keyed argument with a reference to the cell containing the province, so that when it’s copied down it picks up the next province."
(province is similar to your Org # in her example)

Mynda gives a good explanation and it would be worth your while having a read.
https://www.myonlinetraininghub.com/getpivotdata-function-power-pivot

Because the replacing of constants is such an exact process, its worth doing only 1 replacement at at time and testing that it works along the way.

A picture of my steps for replacing the 2021 Year with a variable are below:

(The date component is usually the trickiest one but the process is the same as the below its just that you will need the Text(cell,format) function to get the format to match the format that the pivot table is using)

1617688186574.png
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Yes! Her videos basically taught me Power Query a few weeks ago! She's great, so I'll definitely check that out. I've watched quite a few already, and it's very possibe that I've already seen this one. But I find that sometimes while watching these videos too early in my learning proces, I don't recall almost as much as I do, but it's still very helpful... then I just revisit them again and again as my level of understanding grows. I've been looking very hard on YT and just online in general for any sort of instrruction on learning how to effectivel yunderstand how to change that formula, terminology, etc, but still haven't come accross anything.

So now I almost have all 18 of my "YESTERDAY" table info cell formulas rewritten and working. I just started on the Month To Date row and so still trying to figure that out. But looks like you just sent an example for the YTD table, is that correct?
 
Upvote 0
looks like you just sent an example for the YTD table, is that correct?

It's just showing you how to go about replacing the constants. To make it specific for YTD,
• you need to point the first cell reference in the formula to your YTD Pivot cell in top left corner.
• remove the Date criteria line
• remove the Month criteria line
 
Upvote 0
Welp, that's it for me tonight. Off for my 10 hour hibernation. Lol
Based on my date being set as 4/2/2021 at $G$3, this is my starting MTD formula (no adjustments made yet):
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'YTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&[237]","[Monthly Orders Reports].[Date (Year)]","[Monthly Orders Reports].[Date (Year)].&[2021]","[Monthly Orders Reports].[Date (Month)]","[Monthly Orders Reports].[Date (Month)].&[Apr]")

And this is my starting YTD formula (again, no adjustments made yet):
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'YTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&[237]","[Monthly Orders Reports].[Date (Year)]","[Monthly Orders Reports].[Date (Year)].&[2021]","[Monthly Orders Reports].[Date (Month)]","[Monthly Orders Reports].[Date (Month)].&[Apr]")

And this is what mynew YTD GS Pivot Table looks like. Everything is exploded.
1617694120124.png
 
Last edited:
Upvote 0
I completely misread your message ast night. I thought you sent a new formula for the year-to-date GS. I just reread it and see that you were showing me your steps for making 2021 a variable, which is SUPER-helpful. Thank you! I was definitely far past the point where I should have went to sleep last night. Lol
 
Upvote 0
Hi Alex! I actually just posted a new question to the site, which is a follow up to our conversation here, and is directly related. I thought it best to start a different thread though, since it's a new thing I need solved, rather than just piling new questions into the same topic. I'll mark this one complete, but still may jump in and out of it as needed. Thanks! And here is the new question if you wish to continue! You've been amazingly helpful!!! ? ? ?
 
Upvote 0
Hi Alex! I actually just posted a new question to the site, which is a follow up to our conversation here, and is directly related. I thought it best to start a different thread though, since it's a new thing I need solved, rather than just piling new questions into the same topic. I'll mark this one complete, but still may jump in and out of it as needed. Thanks! And here is the new question if you wish to continue! You've been amazingly helpful!!! ? ? ?

Sounds good. The link was handy. I had a look. Its not something I know of the top of my head, so I will leave it for someone else to answer at this stage.
The new thread is starting to overlap into Power BI territory for which there is a separate stream in the forum, so hopefully someone looks at both streams.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top