<?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: Modifying DAX Formula for Age Calculation to Include Active Employees Hired Before the Selected Year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Modifying-DAX-Formula-for-Age-Calculation-to-Include-Active/m-p/3542076#M136136</link>
    <description>&lt;P&gt;Looks like you have an active relationship between Calender and&amp;nbsp; hr_coredata[DateofHire]. You want to include all employees hired before the end of the selection year. I suggest changing the measure like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Age Measure =
VAR _selyear =
    MAX(_Calendar[Year])
VAR _age =
    CALCULATE(
        DATEDIFF(SELECTEDVALUE(hr_coredata[DOB]),DATE(_selyear, 12, 31 ), YEAR ), 
        ALL(_Calendar),_Calendar[Year]&amp;lt;=_selyear)
RETURN
_age&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 10:03:42 GMT</pubDate>
    <dc:creator>sjoerdvn</dc:creator>
    <dc:date>2023-11-20T10:03:42Z</dc:date>
    <item>
      <title>Modifying DAX Formula for Age Calculation to Include Active Employees Hired Before the Selected Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Modifying-DAX-Formula-for-Age-Calculation-to-Include-Active/m-p/3541978#M136127</link>
      <description>&lt;P&gt;I used the DAX formula below to create a list of active employees with their corresponding ages based on the latest year available from my Year visual filter using Between style for my slicer.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Age &lt;/SPAN&gt;&lt;SPAN&gt;Measure&lt;/SPAN&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SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;12&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;31&lt;/SPAN&gt;&lt;SPAN&gt; ), &lt;/SPAN&gt;&lt;SPAN&gt;YEAR&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;_age&lt;BR /&gt;&lt;BR /&gt;How can I achieve the same results if I used the dropdown style that only allows a single selection. Currently, if I choose a single year, I will only get the list of active employees hired from the year, ignoring any active employees that are hired from previous year.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have a calendar table and an hr_coredata table have the following columns -- [Employee_Name], [DOB] for birthdate, and [DateofHire] for reference. Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Nov 2023 09:06:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Modifying-DAX-Formula-for-Age-Calculation-to-Include-Active/m-p/3541978#M136127</guid>
      <dc:creator>dataaanana</dc:creator>
      <dc:date>2023-11-20T09:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying DAX Formula for Age Calculation to Include Active Employees Hired Before the Selected Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Modifying-DAX-Formula-for-Age-Calculation-to-Include-Active/m-p/3542076#M136136</link>
      <description>&lt;P&gt;Looks like you have an active relationship between Calender and&amp;nbsp; hr_coredata[DateofHire]. You want to include all employees hired before the end of the selection year. I suggest changing the measure like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Age Measure =
VAR _selyear =
    MAX(_Calendar[Year])
VAR _age =
    CALCULATE(
        DATEDIFF(SELECTEDVALUE(hr_coredata[DOB]),DATE(_selyear, 12, 31 ), YEAR ), 
        ALL(_Calendar),_Calendar[Year]&amp;lt;=_selyear)
RETURN
_age&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:03:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Modifying-DAX-Formula-for-Age-Calculation-to-Include-Active/m-p/3542076#M136136</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2023-11-20T10:03:42Z</dc:date>
    </item>
  </channel>
</rss>

