• 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

Combine rows keeping earliest and latest date|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Combine rows keeping earliest and latest date|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 QueryCombine rows keeping earliest and l…
sp_PrintTopic sp_TopicIcon
Combine rows keeping earliest and latest date
Avatar
katerina Bsk

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
August 9, 2022
sp_UserOfflineSmall Offline
1
August 9, 2022 - 7:10 pm
sp_Permalink sp_Print sp_EditHistory

Hi,

I am working with employee records and I am trying to calculate years in company.

As many employees are working have short term contracts I have many entries/rows per employee with hire and termination date.

For each employee I want to have in a single row the employee's earlier hire date and latest termination date.

How can I do that in excel query?

Many thanks in advance

Kat

sp_AnswersTopicSeeAnswer See Answer
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 441
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
August 9, 2022 - 7:20 pm
sp_Permalink sp_Print

Hi Kat,

It would help if you could upload a file resembling your real one, though without real persons names. That way, it's easier to provide a solution.

R

Avatar
katerina Bsk

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
August 9, 2022
sp_UserOfflineSmall Offline
3
August 9, 2022 - 9:53 pm
sp_Permalink sp_Print

Thank you R for asking that!

It made me realize that my question was not correct.

These are my data:

Name ID Hire Date Term Date Contract Duration (months) Position
Kat Bs 123 1/1/2020 3/1/2020 2 Assistant Waiter
Kat Bs 123 2/1/2022 (today) 6 Assistant Waiter
Jonh Smith 456 1/1/2022 2/1/2022 1 Assistant Waiter
Jonh Smith 456 2/2/2022 5/1/2022 2 Head Waiter

 

So in fact what I need is to calculate the sum of months per employee.

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 441
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
August 10, 2022 - 1:30 am
sp_Permalink sp_Print

I believe you can just group by Name (or ID) summing the Contracts Duration column. But to be sure, how would you want to summarise the date you provided?

sp_AnswersTopicAnswer
Answers Post
Avatar
katerina Bsk

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
August 9, 2022
sp_UserOfflineSmall Offline
5
August 10, 2022 - 11:44 pm
sp_Permalink sp_Print

Thank you very much!

I wasn't aware of the grouping feature! It works great for me!

Avatar
katerina Bsk

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
August 9, 2022
sp_UserOfflineSmall Offline
6
August 11, 2022 - 12:04 am
sp_Permalink sp_Print

If possible, could you please also tell me how I can keep only rows for which the Term date was within the last week (or month)?rnEvery week I want to run a query giving me a list of employees leaving the company within the last week.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Velouria, Dario Serrati, Valentyn Kristioglo, Nada Perovic, Andrew Er
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Raj Mattoo
Mark Luke
terimeri dooriyan
Jack Aston
AndyC
Denise Lloyd
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Forum Stats:
Groups: 3
Forums: 24
Topics: 6219
Posts: 27279

 

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