<?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: HeadCount by type in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196246#M19037</link>
    <description>&lt;P&gt;ok, getting a bit closer.&amp;nbsp; Still not sure how to do the final count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;employed = 
var d=max(Calendar[date])
var emp=CALCULATE(LASTNONBLANK(Table[ID],1),CROSSFILTER(Calendar[date],Table[RH_HIST_LABORAL.FECHA_MOV],None))
var lastd=CALCULATE(max(Table[RH_HIST_LABORAL.FECHA_MOV]),ALL(Table),Table[ID]=emp,Table[RH_HIST_LABORAL.FECHA_MOV]&amp;lt;=d,Table[Movimiento] in {"ALTA","BAJA POR CAMBIO DE EMPRESA","BAJO POR RENUNCIA VOLUNTARIA","REINGRESO"})
var lastev=CALCULATE(max(Table[Movimiento]),All(table),Table[ID]=emp,Table[RH_HIST_LABORAL.FECHA_MOV]=lastd)
return left(lastev,4)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 02 Jul 2020 00:23:51 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2020-07-02T00:23:51Z</dc:date>
    <item>
      <title>HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196060#M19030</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to calculate the head count on this database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the table RH Total, there are 3 fields were going to use: ID, RH_HIST_LABORAL.FECHA_MOV, Movimiento.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ID: Employee ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RH_HIST_LABORAL.FECHA_MOV: Movement Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Movimiento: Movement type&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FECHA_BAJA: End Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The field RH_HIST_LABORAL.FECHA_MOV indicates which date a change by the HR excecutive was made.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Movimiento "ALTA" means a person (ID) was hired, "REINGRESO" means a person was rehired and gets his last same ID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In movimiento anything that contains BAJA means this person stopped working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We need to know the daily, monthly &amp;amp; yearly head count, I attached the example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A title="Example" href="https://drive.google.com/drive/folders/19Gystr2uB1tIWy0mpLM3LFuhTeVte0-3?usp=sharing" target="_self"&gt;https://drive.google.com/drive/folders/19Gystr2uB1tIWy0mpLM3LFuhTeVte0-3?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 20:57:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196060#M19030</guid>
      <dc:creator>SergioGG86</dc:creator>
      <dc:date>2020-07-01T20:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196210#M19036</link>
      <description>&lt;P&gt;So basically for each employee and day in your dates table you need to calculate if that employee was employed on that day or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Employed means the ALTA or REINGRESO&amp;nbsp; events are the last event in the past or today. If the BAJA/BAJO event is the last one today or in the past then the employee has left.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We also need to ignore all the other events .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;employed = 
var emp=max(Table[ID])
var d=max(Calendar[date])
var lastd=CALCULATE(max(Table[RH_HIST_LABORAL.FECHA_MOV]),All(table),Table[ID]=emp,Table[RH_HIST_LABORAL.FECHA_MOV]&amp;lt;=d,Table[Movimiento] in {"ALTA","BAJA POR CAMBIO DE EMPRESA","BAJO POR RENUNCIA VOLUNTARIA","REINGRESO"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think these are ok steps but it starts to get thin. Maybe someone else can step in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 23:24:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196210#M19036</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-07-01T23:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196246#M19037</link>
      <description>&lt;P&gt;ok, getting a bit closer.&amp;nbsp; Still not sure how to do the final count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;employed = 
var d=max(Calendar[date])
var emp=CALCULATE(LASTNONBLANK(Table[ID],1),CROSSFILTER(Calendar[date],Table[RH_HIST_LABORAL.FECHA_MOV],None))
var lastd=CALCULATE(max(Table[RH_HIST_LABORAL.FECHA_MOV]),ALL(Table),Table[ID]=emp,Table[RH_HIST_LABORAL.FECHA_MOV]&amp;lt;=d,Table[Movimiento] in {"ALTA","BAJA POR CAMBIO DE EMPRESA","BAJO POR RENUNCIA VOLUNTARIA","REINGRESO"})
var lastev=CALCULATE(max(Table[Movimiento]),All(table),Table[ID]=emp,Table[RH_HIST_LABORAL.FECHA_MOV]=lastd)
return left(lastev,4)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 00:23:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1196246#M19037</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-07-02T00:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207484#M19409</link>
      <description>&lt;P&gt;&amp;nbsp;you need to have an active relationship between the table date and the employee table?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 21:31:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207484#M19409</guid>
      <dc:creator>SergioGG86</dc:creator>
      <dc:date>2020-07-07T21:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207541#M19411</link>
      <description>&lt;P&gt;yes, as we use a CROSSFILTER(none) which basically multiplies the employee list with the dates table.&amp;nbsp; You may also need the relationship in other parts of your report.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 21:58:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207541#M19411</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-07-07T21:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207559#M19413</link>
      <description>&lt;P&gt;Quote: "&lt;SPAN&gt;We need to know the daily, monthly &amp;amp; yearly head count" - For monthly and yearly, do you mean at the end of the month or year? For employee 13491 you would then also miss all the events that happen in May 2016.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 22:09:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207559#M19413</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-07-07T22:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: HeadCount by type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207614#M19414</link>
      <description>&lt;P&gt;&lt;A title="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Impossible-Head-Count/m-p/1207547#M19412" href="http://Followup" target="_self"&gt;Please follow up to the latest thread:&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Impossible-Head-Count/m-p/1207547#M19412" href="http://Followup" target="_self"&gt;Followup&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 23:16:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/HeadCount-by-type/m-p/1207614#M19414</guid>
      <dc:creator>SergioGG86</dc:creator>
      <dc:date>2020-07-07T23:16:13Z</dc:date>
    </item>
  </channel>
</rss>

