• 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

Earliest Date|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Earliest 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 QueryEarliest Date
sp_PrintTopic sp_TopicIcon
Earliest Date
Avatar
Ken Gulick

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 21, 2019
sp_UserOfflineSmall Offline
1
April 11, 2020 - 2:29 am
sp_Permalink sp_Print

I am trying to get the earliest date / minimum value from a field (in power query).

In my data table in an Excel table, each  line/record has a stamp date for when the row occurs. I want to add a new column that shows the earliest start date.

How can I do that in Power Query?

row    stamp date    start date
1       3-31-20         3-31-20
2       4-1-20           3-31-20
3       4-2-20           3-31-20
4       4-3-20           3-31-20
5       3-31-20         3-31-20
6       4-1-20           3-31-20
7       3-31-20         3-31-20

sp_AnswersTopicSeeAnswer See Answer
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4447
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
April 11, 2020 - 8:18 pm
sp_Permalink sp_Print

Hi Ken,

Add a custom column that returns the 'List.Min' for the Stamp Date column. The formula looks like this:

=List.Min(#"Changed Type with Locale"[#"stamp date"])

Remember, Power Query is case sensitive so you may need to change the column name to suit. You'll also need to change the last step reference to suit your query.

Mynda

Avatar
Ken Gulick

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 21, 2019
sp_UserOfflineSmall Offline
3
April 14, 2020 - 3:03 am
sp_Permalink sp_Print

That's what I did, but it returned the date of the record.

Since it did not work with DateTime, I tried Date, and then record Index.  Same result.  File attached.

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OpCenter", type text}, {"item", type text}, {"start", type datetime}, {"stop", type datetime}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Added Custom3" = Table.AddColumn(#"Added Index", "Min Index", each List.Min({[Index]})),
#"Added Custom" = Table.AddColumn(#"Added Custom3", "Min Start", each List.Min({[start]})),
#"Added Custom2" = Table.AddColumn(#"Added Custom", "Start Date", each DateTime.Date([start])),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom2",{{"Start Date", type date}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type1", "Min Start Date", each List.Min({[Start Date]}))
in
#"Added Custom1"

What am I missing?

Thanks,

Ken

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4447
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
April 14, 2020 - 9:17 am
sp_Permalink sp_Print

Hi Ken,

Our formulas are not the same. Your formula is:

=List.Min({[start]})

Mine is:

=List.Min(#"Changed Type"[#"start"])

Replace your "Added Custom" step formula with the one above.

This yields a different result (i.e. April 8, 2020 7:00:00 AM) because it's referring to a step, not just a record.

Mynda

sp_AnswersTopicAnswer
Answers Post
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Velouria, Jack Brett, Rocco Pinneri, LAFONSO HERNANDEZ
Guest(s) 10
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:
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Forum Stats:
Groups: 3
Forums: 24
Topics: 6211
Posts: 27239

 

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