<?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: Calculate Planned and Worked hours by employee and activity in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1320779#M23232</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have had a look at your file, and read through your post a couple of times, but I don't understand what you are having problems with. Would you care to explain what you are having trouble with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Sturla&lt;/P&gt;</description>
    <pubDate>Mon, 24 Aug 2020 22:42:20 GMT</pubDate>
    <dc:creator>sturlaws</dc:creator>
    <dc:date>2020-08-24T22:42:20Z</dc:date>
    <item>
      <title>Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1296958#M22395</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PBIX file:&amp;nbsp;&lt;A href="https://mega.nz/file/UEs11CgJ#tNnGfRUsIhBcfxOjOFXpQkYIwQ7G3_RbaRx-yb419m0" target="_blank"&gt;https://mega.nz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying show in the same visual table, the SUM of &lt;STRONG&gt;Planned&lt;/STRONG&gt; and &lt;STRONG&gt;Worked&lt;/STRONG&gt; hours (type INT e.g.: 08, 25) by employee and activity, but for each Month Date and Employee, is showwing all the activitys from dProjects as 0. In my model view, on visual "Table1" you will see what I'm saying.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The expected visual result that I'm looking for:&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;we have 4 combinations that could happen:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Planned = 0 / Worked = 0 (no planned activitys and no register of work hours)&lt;/LI&gt;&lt;LI&gt;Planned = 168 / Worked = 0 (planned to work in some activity but not register the hours as worked yet)&lt;/LI&gt;&lt;LI&gt;Planned = 0 / Worked = 168 (not planned to work but register hours as worked)&lt;/LI&gt;&lt;LI&gt;Planned = 168 / Worked = 168 (all's good! planned to work and register the worked hours for the activity)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;When both measures of Hours been zero (0), the fields of project data should be blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some one could try help me?&lt;/P&gt;&lt;P&gt;I don't know if my model data is the best to achive this result, but if we can solve this if DAX in each measure, would be great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lucio&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 17:05:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1296958#M22395</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-14T17:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1320779#M23232</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have had a look at your file, and read through your post a couple of times, but I don't understand what you are having problems with. Would you care to explain what you are having trouble with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Sturla&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 22:42:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1320779#M23232</guid>
      <dc:creator>sturlaws</dc:creator>
      <dc:date>2020-08-24T22:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1320820#M23234</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="88633" data-lia-user-login="sturlaws" class="lia-mention lia-mention-user"&gt;sturlaws&lt;/a&gt;&amp;nbsp;, thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I need analyse for each month/employee (Table 1 for tests), if the employee has Planned or Worked hours in some activities, but in my current model, for each activity, are showing 0 for all (dProjects registers) for each employee.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this image for "Funcionario 1 EFETIVO", just the highlighted values (168 / 168) are right because this employee has these SUM hours in both fact tables for this month (Jun-2020):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But, for the other ACTIVE employees ("FUNCIONARIO 2"), as he &lt;STRONG&gt;don't have&lt;/STRONG&gt; values in fact tables, all the colouns values (from dProject) should be blank, and the measures (planned / worled) should show just (0 / 0), in one single row by each employee.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My visual "Tabela 2" has the value in the measures right for each employee context, but if I add the values of dProject (Table 1), the table will show extra wrong data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope now I had provided a better explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR.&lt;/P&gt;&lt;P&gt;Lúcio&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 23:32:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1320820#M23234</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-24T23:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1330228#M23558</link>
      <description>&lt;P&gt;Ok, I think I got it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a solution for you, but it is not quite straight forward.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you have to add a dummy row to dProjetos. On this row set 'dProjetos'[ID_ACTIVITY]=-1, leave all other fields blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next change your measure to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Planned Hours =
VAR _aID =
    CALCULATE ( MIN ( dProjetos[ID_ACTIVITY] ) )
VAR _tmpSum =
    CALCULATE ( SUM ( f_Planejamento_Det[Planned Hours] ), ALL ( dProjetos ) )
RETURN
    SUM ( f_Planejamento_Det[Planned Hours] )
        + IF ( _aID = -1 &amp;amp;&amp;amp; ISBLANK ( _tmpSum ), 0, BLANK () )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and see if that does the trick.&lt;BR /&gt;&lt;BR /&gt;And do the same thing to the worked hours and f_Apontamentos.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Sturla&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 21:27:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1330228#M23558</guid>
      <dc:creator>sturlaws</dc:creator>
      <dc:date>2020-08-27T21:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1336727#M23777</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="88633" data-lia-user-login="sturlaws" class="lia-mention lia-mention-user"&gt;sturlaws&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Your solution atends whats I need! &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 just need try let this one a litthe bit more perfomatic, because I had arround 1000 active employess to be analyse, so If don't have any filter in the page by employee and month, your original measure do not finish the DAX query (There's not enough memory").&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I add the conditional to check if is active as below, the table takes 65s:&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;Do you have any ideia to improve your measure? or may creat a DAX table with these data equal to my table1 visual?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lúcio&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:45:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1336727#M23777</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-31T16:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Planned and Worked hours by employee and activity</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1337165#M23789</link>
      <description>&lt;P&gt;The reason it takes so long, is that when I try to change the measure to return 0 for workers where there are no projects, the expression is evaluated for every combination of worker and project/activity. For your sample file it runs fine, but for large numbers of workers and/or projects, Power BI will run out of memory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggeling to find a workaround, but could you try to set the relationship between dProjetos and the two fact tables to inactive and write the measures like this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Worked Hours =
VAR _tmp =
    CALCULATE (
        SUM ( f_Apontamentos[Register Hours] ),
        USERELATIONSHIP ( dProjetos[ID_ACTIVITY], f_Apontamentos[PKNI_ACTIVITY_ID] )
    )
RETURN
    IF (
        ISBLANK ( SUM ( f_Apontamentos[Register Hours] ) )
            &amp;amp;&amp;amp; CALCULATE ( SELECTEDVALUE ( dProjetos[ID_ACTIVITY] ) ) = -1,
        0,
        _tmp
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(still with the dummy row in dProjetos)&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 22:23:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Planned-and-Worked-hours-by-employee-and-activity/m-p/1337165#M23789</guid>
      <dc:creator>sturlaws</dc:creator>
      <dc:date>2020-08-31T22:23:18Z</dc:date>
    </item>
  </channel>
</rss>

