• 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
    • 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

Duration in matrix - difference between two time record|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Duration in matrix - difference between two time record|Power Query|Excel Forum|My Online Training Hub

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 QueryDuration in matrix - difference bet…
sp_PrintTopic sp_TopicIcon
Duration in matrix - difference between two time record
Avatar
Sunil lal
Member
Members

Power Query

Power Pivot

Power BI
Level 0
Forum Posts: 7
Member Since:
July 3, 2022
sp_UserOfflineSmall Offline
1
January 5, 2023 - 11:18 pm
sp_Permalink sp_Print

Hi Everyone,

I'm looking for ideas to calculate the diference between the time values, at first in power query I calculated using the following by adding a cusotm coloumn.

Dhanil_0-1672921720572.png

The coloumn added in time format showed error, hence it was converted to whole numbers

Dhanil_2-1672921890586.png

Further the difference showing up in the matrix is not matching up to the actual difference

Dhanil_1-1672921813277.png

The time difference is not adding up, is there a measure or any menthod that can help me solve the issue ? - DATEDIFF is not showing up when I type in adding custom column

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
January 6, 2023 - 1:19 am
sp_Permalink sp_Print

Hi,

you probably intended to upload some screenshots, but they didn't come through. Please try again by clicking "Attachments", select the pictures to upload and then "Start upload". Even better you can upload a file that includes your data and queries.

Riny

Avatar
Sunil lal
Member
Members

Power Query

Power Pivot

Power BI
Level 0
Forum Posts: 7
Member Since:
July 3, 2022
sp_UserOfflineSmall Offline
3
January 6, 2023 - 2:51 pm
sp_Permalink sp_Print

Hi Riny,

This is the images that I intended to attach - it explains the formula used in the custom coloumn , the result of the formula and the desired outcome.

Regards,
Dhanil Sunil 1.pngImage Enlarger

2.pngImage Enlarger

3.PNGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage 1.png (68 KB)
  • sp_PlupImage 2.png (60 KB)
  • sp_PlupImage 3.PNG (80 KB)
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
January 6, 2023 - 4:05 pm
sp_Permalink sp_Print

To calculate time spent in Power Query, first select the End time column, press control and then the Start time column. On the Add Column tab press the Time button and choose Subtract. This will generate the appropriate code that calculates duration for you. It may look something like this:

Table.AddColumn(#"Previous Step", "Time spent", each [End] - [Start], type nullable duration)

Don't use the Duration.Minutes function as it only returns the minutes portion of a duration. So, it the total duration was 3 hours 10 minutes, it returns the number 10. And you should not set the data type to Time as that will return an error, as you have noticed.

With regard to DATEDIF, that function does not exist in Power Query (M-code).

Avatar
Sunil lal
Member
Members

Power Query

Power Pivot

Power BI
Level 0
Forum Posts: 7
Member Since:
July 3, 2022
sp_UserOfflineSmall Offline
5
January 6, 2023 - 6:09 pm
sp_Permalink sp_Print

Hi Riny,

Thank you for the solution, this has worked for 70% of the data - except for few.

In the image below the first two columns are the time spread and the last column is the time taken. As you can see 14: 38 to 14: 45 is showing 7 minutes.

sp_PlupAttachments Attachments
  • sp_PlupImage 4.PNG (36 KB)
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
6
January 6, 2023 - 6:41 pm
sp_Permalink sp_Print

Isn't that correct?
14:45 is 7 minutes after 14:38.

Avatar
Sunil lal
Member
Members

Power Query

Power Pivot

Power BI
Level 0
Forum Posts: 7
Member Since:
July 3, 2022
sp_UserOfflineSmall Offline
7
January 6, 2023 - 7:47 pm
sp_Permalink sp_Print

Hi Riny,

Pardon the typo, it's showing 0 minutes in the subtraction tab at the right end, not 7 minutes.

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
8
January 6, 2023 - 8:29 pm
sp_Permalink sp_Print sp_EditHistory

Not sure about what that columns represents, but I suspect that you are expressing the total number of minutes as a portion of a whole day, containing 1440 minutes.

3hrs, 19min = 199min / 1440 = 0.138894 = 0.14 rounded
2hrs, 18min = 138min / 1440 0.095833 = 0.10 rounded

Similarly, 7min / 1440 = 0.004861 = 0.00 rounded

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 170
Currently Online: Bouskila stephanie, Brenda Krol, James Hwang
Guest(s) 42
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1431
Anders Sehlstedt: 848
Velouria: 574
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 213
A.Maurizio: 202
Aye Mu: 201
Jessica Stewart: 185
Newest Members:
David Collins
Andras Marsi
Orimoloye Funsho
YUSUF IMAM KAGARA
PRADEEP PRADHAN
Vicky Otosnika
Abhishek Singh
Kevin Sojourner
Kara Weiss
And Woox
Forum Stats:
Groups: 3
Forums: 24
Topics: 6047
Posts: 26544

 

Member Stats:
Guest Posters: 49
Members: 31497
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Riny van Eekelen
© Simple:Press —sp_Information
  • 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
 
  • About My Online Training Hub
  • Contact
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

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.

Download A Free Copy of 100 Excel Tips & Tricks

excel tips and tricks ebook

We respect your privacy. We won’t spam you.

x