<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Average Tenure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1721389#M35609</link>
    <description>&lt;P&gt;It's working, Thank you so much.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 04:54:30 GMT</pubDate>
    <dc:creator>Vinay06</dc:creator>
    <dc:date>2021-03-15T04:54:30Z</dc:date>
    <item>
      <title>Average Tenure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720783#M35588</link>
      <description>&lt;P&gt;Hi, I want to calculate Average tenure using 'Hiring Date' and 'Leaving date'.but in 'Leaving date' column there are some empty rows, i want replace empty rows with current date. so please help me in creating a dax code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Mar 2021 12:09:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720783#M35588</guid>
      <dc:creator>Vinay06</dc:creator>
      <dc:date>2021-03-14T12:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Average Tenure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720816#M35590</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="283991" data-lia-user-login="Vinay06" class="lia-mention lia-mention-user"&gt;Vinay06&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to leave the blank Leaving Dates as they are, and in those cases treat "today" as the Leaving Date (when the measure is evaluated), you can write a measure like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average Tenure (Days) = 
VAR TodayDate = TODAY ()
RETURN
    AVERAGEX ( 
        YourTable,
        COALESCE ( YourTable[Leaving Date], TodayDate ) -- Blanks changed to TODAY()
        - YourTable[Hiring Date]
    )&lt;/LI-CODE&gt;
&lt;P&gt;The above measure calcualtes tenure in days by subtracting dates. You can instead use DATEDIFF if you need something different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Sun, 14 Mar 2021 13:09:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720816#M35590</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-03-14T13:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Average Tenure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720945#M35597</link>
      <description>&lt;P&gt;Thanks for spending your time for me. Actually i want to include those blank leaving dates but instead of blank value i want to replace them with today date,and can you provide dax code for calculating averege tenure as well.&lt;BR /&gt;1) calculate average tenure using Hiring date and Leaving date&lt;/P&gt;&lt;P&gt;2) Replace blank values in Leaving date with today date.&lt;/P&gt;&lt;P&gt;please provide me&amp;nbsp; with a complete dax code for above mentioned points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Mar 2021 18:27:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1720945#M35597</guid>
      <dc:creator>Vinay06</dc:creator>
      <dc:date>2021-03-14T18:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Average Tenure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1721005#M35599</link>
      <description>&lt;P&gt;You're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the above measure is doing what you want but let me check it with you. Let me know.&lt;/P&gt;
&lt;P&gt;I have attached a sample PBIX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to explain the measure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;It iterates row by row over the table (named YourTable as a placeholder)&lt;/LI&gt;
&lt;LI&gt;For the purpose of the measure, blank Leaving Dates are replaced with TODAY() using the COALESCE function, then the Hiring Date is subtracted from the Leaving Date.&lt;/LI&gt;
&lt;LI&gt;So the blank Leaving Dates remain blank in the table, and are just overridden for the measure calculation itself.&lt;/LI&gt;
&lt;LI&gt;One thing to note is that TODAY() is determined when the measure is calculated in the report, but query results can be cached, so that if you left a report open from one day to the next, you might get results that are based on a past value of TODAY().&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here are some sample outputs using a subset of your posted data plus some additional rows added by me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;In case you were considering adding a column that replaces blank Leaving Dates with TODAY(), you would just need to be aware that this column would generally only be updated when refresh occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Mar 2021 19:53:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1721005#M35599</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-03-14T19:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Average Tenure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1721389#M35609</link>
      <description>&lt;P&gt;It's working, Thank you so much.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 04:54:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Tenure/m-p/1721389#M35609</guid>
      <dc:creator>Vinay06</dc:creator>
      <dc:date>2021-03-15T04:54:30Z</dc:date>
    </item>
  </channel>
</rss>

