Help with Date portion of GETPIVOTDATA formula

ExcelAtEverything

Active Member
Joined
Jan 30, 2021
Messages
351
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I have a project I'm working on and I am now in the Month To Date (MTD) section, and am running into a problem setting up a formula which will always grab the MTD number of the current month (which are the numbers that appear in the Pivot Table below). The Pivot table was built using Power Query & loaded into Data Model. The MTD number needs to be based on the entire month of whatever yesterday's date was, so that on days like today (1st of the month), the sheet shows the month of March. The formula will also need to work so that I can pull it down and it will translate to the other Org numbers (located in the Pivot Table under "Row Labels"

This is the formula I have in G16 now, which seems to work, but I can't keep that "Mar" date info in there obviously. When I try to erase the date part of the formula however, the results grow significantly larger for whatever reason (I'm still new to Pivot Tables, so I don't understand why just yet). By the way, "Monthly Orders Reports" is just the name of the folder on my desktop holding all of the Excel docs with the info that feeds the Data Model. Thanks for assistance.
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'MTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&["&[@[Org '#]]&"]","[Monthly Orders Reports].[Date (Month)]","[Monthly Orders Reports].[Date (Month)].&[Mar]")
1617296251998.png

The Formula is in 'Main' Tab.
The Pivot Table is in 'MTD GS' tab.
1617294047730.png
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
date part: [mar] ++> "[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1;"mmm")&"]"
 
Upvote 0
date part: [mar] ++> "[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1;"mmm")&"]"
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'MTD GS'!$B$3,"[Monthly Orders Reports].[Org #]",date part: [mar] ++> "[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1;"mmm")&"]"

Hi again Mart37!, I've tried your code, and also tried moving it to several different positions. Every place I put it, I get this error. Am I putting it in wrong?
1617313108049.png

[mar] ++> "[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1;"mmm")&"]"
 
Upvote 0
I didn't mean to have that "date part:" in there. Lol! That was removed hours ago right after pasted it into my sheet. I didn't realize iI uploaded that incorrectly here until maybe a minute ago. But no, still doesn't work.
 
Upvote 0
=GETPIVOTDATA("[Measures].[Sum of Line Item Total]",'MTD GS'!$B$3,"[Monthly Orders Reports].[Org #]","[Monthly Orders Reports].[Org #].&["&[@[Org '#]]&"]","[Monthly Orders Reports].[Date (Month)]","[Monthly Orders Reports].[Date (Month)].&["&TEXT(TODAY()-1;"mmm")&"]")
 
Upvote 0
Behind the -1 replace ; with ,
Bam! That worked like a charm, mart37!

I need to ask you a question though. I notice that you have (TODAY()-1,"mmm" in the date-finding portion of the formula. Does that make it so that on May 1st, it will (correctly) pull the monthly numbers for March instead of April (of which there won't yet be any numbers until that 1st day of the month has been completed)? That's what I hope it will do, but again I'm still new to Pivot Tables so I don't quite fully understand every aspect of this formula.

The reason I ask is because I asked someone in a different forum how to go about that, because I noticed that it happened to me on April 1st (before you gave me this formula).

I just want to make sure I don't cross-post or waste anyone's time unnecessarily. Thanks for this answer!!! You are a rockstar!
 
Upvote 0
If today is 1 May then TODAY()-1 is 30 April. So you get the data of April. If there is no data you get an error.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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