• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Convert Years/Days to Months|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Convert Years/Days to Months|Power Query|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 QueryConvert Years/Days to Months
sp_PrintTopic sp_TopicIcon
Convert Years/Days to Months
Avatar
Tyler
Upstate New York
Member
Members
Level 0
Forum Posts: 34
Member Since:
February 12, 2018
sp_UserOfflineSmall Offline
1
August 30, 2019 - 10:25 pm
sp_Permalink sp_Print

My goal is to covert hired dates to months with the company. I used the PQ to transform the date to age, then transformed the age to years using the Duration button, however, there is no months option in the dropdown, only total years, days, hours etc. Is there a way to transform to total months using the options in the transform ribbon or does this require a custom function using M code?

 

Thanks!

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4513
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
August 31, 2019 - 4:32 pm
sp_Permalink sp_Print

Hi Tykru,

There's no built in way to calculate it but this post offers a solution. However, it is simpler to do this calculation in Power Pivot using the DATEDIF function.

Mynda

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1824
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
3
August 31, 2019 - 5:41 pm
sp_Permalink sp_Print

Hi,

If you have the age in years, adding a column that multiplies the age by 12 should be enough, normally the age in years should have decimals, so 3.25 years*12 = 39 months for example.

Avatar
Tyler
Upstate New York
Member
Members
Level 0
Forum Posts: 34
Member Since:
February 12, 2018
sp_UserOfflineSmall Offline
4
September 1, 2019 - 6:38 am
sp_Permalink sp_Print

Awesome, I will take a look at both and see what works for me. I considered using DAX in Power Pivot but am only working from one table so I didn't add to PP data model because how simplistic my solution is. Can you use PP to create measures with only one table?

 

Thanks!

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4513
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
5
September 1, 2019 - 9:15 am
sp_Permalink sp_Print

Yes, DAX measures can be written for one table.

Avatar
Tyler
Upstate New York
Member
Members
Level 0
Forum Posts: 34
Member Since:
February 12, 2018
sp_UserOfflineSmall Offline
6
September 2, 2019 - 11:32 am
sp_Permalink sp_Print

I've tried both Catalin's and your suggestion and they work great. However, when I round both 1 decimal place, the DAX version will round way up (i.e. the M code result will be 11.2 and the DAX will round up to 12.0). Any idea why? 

 

Thanks,

Tyler

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Geoff McClure, Riny van Eekelen, Cassie Bernier
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 215
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Ngoc Qui Nguyen
Clement Mansfield
Rose .
Bindu Menon
Baruch Zemer
Purple RainbowBenefactor
MOTH Junkie
Forum Stats:
Groups: 3
Forums: 24
Topics: 6350
Posts: 27773

 

Member Stats:
Guest Posters: 49
Members: 32317
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.