• 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

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

vba course banner

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: 490
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: 490
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: 490
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: 490
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: 245
Currently Online: ash seth, Andrew Wilkie, Scott Miller, Les Harold
Guest(s) 7
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: 217
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
David du Toit
leandro barbarini
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27795

 

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