• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Cube Functions - Dynamic period selection|Power Pivot|Excel Forum|My Online Training Hub

You are here: Home / Cube Functions - Dynamic period selection|Power Pivot|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower PivotCube Functions - Dynamic period sel…
sp_PrintTopic sp_TopicIcon
Cube Functions - Dynamic period selection
Avatar
baxbax
Member
Members

Power Query

Power Pivot
Level 0
Forum Posts: 105
Member Since:
July 11, 2016
sp_UserOfflineSmall Offline
1
February 12, 2022 - 10:13 pm
sp_Permalink sp_Print

Hi,

First of all thanks for the recent post on Cube functions, really helpful. I have now started to investigate using these as I can see lots of uses.

Inevitably this has prompted some questions. The first one is how can I automatically get the formulas to pick up a year and month based on a cell entry.

I want to create a report that shows data for the current year and a specified month and then next to that show the data for the same month but for the previous year. I want to allow the user to select the year and month they want to look at and then the data changes based on these choices.

I have used your Cube functions file (I hope you don't mind) and updated it to show the data for January 2021 and next to it January 2020. The file is attached. I have done this by specifically referencing the year within the formula. The month is currently picked up from a header cell but again the month is specifically referenced in the formula. The following shows the formula as it is. Cell D6 is the month.

=CUBEVALUE("ThisWorkbookDataModel",$B$5,$C8,D$6,"[Data].[Date (Year)].&[2021]")

Ideally what I would like to do is to have a list of years and months that the user can select from and then these are used in the formulas.

If I can work this out I can see a bright future for Cube functions in my reporting set up!

Thanks

 

Bax

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
February 14, 2022 - 2:13 pm
sp_Permalink sp_Print

Hi,

Have you tried:

=CUBEVALUE("ThisWorkbookDataModel",$B$5,$C8,D$6,"[Data].[Date (Year)].&["&D8&"]")

Change D8 to your cell where the Year value is.

Avatar
baxbax
Member
Members

Power Query

Power Pivot
Level 0
Forum Posts: 105
Member Since:
July 11, 2016
sp_UserOfflineSmall Offline
3
February 14, 2022 - 9:59 pm
sp_Permalink sp_Print

Hi Catalin,

Thanks for the reply. I know that you can reference a cell as you have but what I was hoping was to have the user select a year and month and then the This Year and Last Year columns automatically update from their selection. I am thinking of something like a validated list for year and one for month but can't work out how to do this. For the year is it possible to somehow do subtraction within the formula so you could say Last Year = This Year - 1. 

Thanks

 

Bax

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
February 15, 2022 - 12:55 am
sp_Permalink sp_Print

Not following...

.[Date (Year)].&["&D8&"]")

In that cell D8, you can put any formula or dropdown with your year values, you need help with adding a dropdown in a cell?

Avatar
baxbax
Member
Members

Power Query

Power Pivot
Level 0
Forum Posts: 105
Member Since:
July 11, 2016
sp_UserOfflineSmall Offline
5
February 15, 2022 - 9:02 pm
sp_Permalink sp_Print

Hi Catalin,

I understand what you are saying and it works fine for the "This Year" column. Is there anyway I can reference the same cell but deduct a year within the formula for the "Last Year" column? 

I think I can work out how to do dropdowns in cells thanks 🙂

Bax

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
February 15, 2022 - 9:18 pm
sp_Permalink sp_Print

I think Catalin's point is that you can do something like:

 

=CUBEVALUE("ThisWorkbookDataModel",$B$5,$C8,D$6,"[Data].[Date (Year)].&["&D8-1&"]")

since you're just concatenating a value into a string.

Avatar
baxbax
Member
Members

Power Query

Power Pivot
Level 0
Forum Posts: 105
Member Since:
July 11, 2016
sp_UserOfflineSmall Offline
7
February 16, 2022 - 3:16 am
sp_Permalink sp_Print

Hi Velouria, that is exactly what I was after. Works fine. Thanks.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Alan Sidman, Rebecca Berneck, Emma Klonowski, Marco Marques, Natasha Smith
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Annie Witbrod
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31888
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.