{"id":34,"date":"2022-02-21T13:52:50","date_gmt":"2022-02-21T13:52:50","guid":{"rendered":"http:\/\/powerbikiss.com\/?p=34"},"modified":"2022-02-21T14:57:39","modified_gmt":"2022-02-21T14:57:39","slug":"how-to-get-the-duration-between-two-datetime-or-date-fields-in-power-bi","status":"publish","type":"post","link":"https:\/\/powerbikiss.com\/?p=34","title":{"rendered":"How to get the duration between two datetime or date fields in Power BI"},"content":{"rendered":"\n<p>I had to do this recently and struggled a bit to begin with. Thankfully once I figured it out it was quite easy to accomplish, like most things, it&#8217;s always easy when you know how. Below is a view of the fields in question in Power Query:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"351\" height=\"280\" src=\"http:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/StartEnd.png\" alt=\"\" class=\"wp-image-35\" srcset=\"https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/StartEnd.png 351w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/StartEnd-300x239.png 300w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/figure>\n\n\n\n<p>What I wanted to get is the duration between the Closed date &amp; the Created Date.<\/p>\n\n\n\n<p><strong>Step 1<\/strong> First add a custom column (Go to Add Column > Custom Column)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"691\" height=\"428\" src=\"http:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image.png\" alt=\"\" class=\"wp-image-36\" srcset=\"https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image.png 691w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-300x186.png 300w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><\/figure>\n\n\n\n<p><strong>Step 2<\/strong> Change the data type to a <strong>Duration<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"209\" height=\"352\" src=\"http:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-3.png\" alt=\"\" class=\"wp-image-39\" srcset=\"https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-3.png 209w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-3-178x300.png 178w\" sizes=\"auto, (max-width: 209px) 100vw, 209px\" \/><\/figure>\n\n\n\n<p><strong>Step 3<\/strong> Go to Transform then Duration &amp; choose the &#8220;Total&#8221; duration time that works best for you. As the time values in my fields where precise to the minute, then minute was good enough for me. \ud83d\ude0a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"243\" src=\"http:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-2-1024x243.png\" alt=\"\" class=\"wp-image-38\" srcset=\"https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-2-1024x243.png 1024w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-2-300x71.png 300w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-2-768x182.png 768w, https:\/\/powerbikiss.com\/wp-content\/uploads\/2022\/02\/image-2.png 1431w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had to do this recently and struggled a bit to begin with. Thankfully once I figured it out it was quite easy to accomplish, like most things, it&#8217;s always easy when you know how. Below is a view of the fields in question in Power Query: What I wanted to get is the duration [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-kiss","category-power-bi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":2,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":47,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/47"}],"wp:attachment":[{"href":"https:\/\/powerbikiss.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/powerbikiss.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}