<?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: How to create multiple dynamic tables of employees and counting unique employees from all of them in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3261294#M120601</link>
    <description>&lt;P&gt;The CROSSJOIN generates all possible combinations of employee and week, and that then allows comparison with the actual combinations where a log sheet was submitted. I think you would need a very large number of employees and a lot of years before you run into serious performance issues - each employee will only generate 52 entries per year.&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 08:16:25 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-05-31T08:16:25Z</dc:date>
    <item>
      <title>How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3257397#M120335</link>
      <description>&lt;P&gt;Hi, I am working on Employee Log Sheet submissions problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Emp_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Project&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/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;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Emma&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Missing&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Emma&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Missing&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Emma&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Drafted&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;It is possible for one employee to be working on multiple projects, like Emma and Leo in the above dataset.&lt;/LI&gt;&lt;LI&gt;The "Status" column states whether the person submitted his logsheet or not. This column has three possible values, "Submitted", "Drafted" and "Missing"&lt;/LI&gt;&lt;LI&gt;Employees submit logsheets on weekly basis.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is to count the&amp;nbsp;&lt;STRONG&gt;unique number of employees who did not submit their log sheet.&amp;nbsp;&lt;/STRONG&gt;Now it is possible that one employee might be on two projects and he submitted logsheet for one project but didn't for the other project (like Emma in Week 1). So in such a case, this employee will be considered as the one who "submitted his logsheet" and will not count towards people who missed their logsheet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly, if a person has "Drafted" his logsheet then again, it will be considered as "missed" timesheet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, to tackle this problem, I made the following DAX to calculate the unique number of employees who missed their Log sheet for a certain week,&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="markup"&gt;Missing Logsheets = 


var text_value = "Submitted"

VAR _Filtered_Table = 
    FILTER(
        'LogSheet', 
        'LogSheet'[Status] = text_value
    )

VAR _Not_Submitted_EmpIDs = 
    EXCEPT(
        VALUES('LogSheet'[Emp_ID]),
        CALCULATETABLE(
            VALUES('LogSheet'[Emp_ID]),
            _Filtered_Table
        )
    )

VAR _Result = COUNTROWS(_Not_Submitted_EmpIDs)

return _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This DAX basically finds all the people who submitted their logsheets (irrespective of whether they had any row with a "missing/drafted" Logsheet) and then using that list of Employees, finds the employees who missed their logsheet and take the count of that table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine for&amp;nbsp;&lt;STRONG&gt;one selected week.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem comes when I filter the results&amp;nbsp;&lt;STRONG&gt;by multiple weeks.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In this case, my requirement slightly changes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate the&amp;nbsp;&lt;STRONG&gt;unique number of employees who missed logsheet in any of the weeks currently selected.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So, for example, if I have selected "Two weeks" (let's say 1 and 2), and one employee submitted his logsheet in the first week, but missed his logsheet in the 2nd week, then he should also&amp;nbsp;&lt;STRONG&gt;count towards the Employees who missed the logsheet submission&amp;nbsp;&lt;/STRONG&gt;(and because he submitted the logsheet in first week, so he will count towards the Employees who submitted logsheets, as well. But this is easy. Main problem comes in Missing Logsheet Employees)&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="markup"&gt;For example, 

If 2 weeks are selected, 

then the Employee "Emma" will count towards "Missing Logsheet Employees" because she didn't submit her logsheet in the week 2 (even though she did submit her logsheet in the first week) 

Similarly, if all 3 weeks are selected, then total number of employees who missed logsheet will be 4 because none of the employees have submitted their logsheet in the third week. &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I tackle this problem? Can anyone help?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The way I see it, I have already created DAX to find the employees who missed their logsheet&amp;nbsp;&lt;STRONG&gt;for one week.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I need to create a variable that can store summarized results against each week. And then I can combine all those results (that is, list of employees missing their logsheet for each week) and then take the unique count of that combined table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I can't seem to find any way to solve this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;If you would like to download the Example Power BI File, you may do so from here:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1vDRG2X4JegnMQFC0GhGaUpUwbP0ThK6E/view?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1vDRG2X4JegnMQFC0GhGaUpUwbP0ThK6E/view?usp=sharing&lt;/A&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 05:40:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3257397#M120335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-29T05:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259502#M120478</link>
      <description>&lt;P&gt;I think you can adapt your existing code to iterate across all selected weeks, whether that is just one week or multiple.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Missing Logsheets =
SUMX (
    VALUES ( 'LogSheet'[Week] ),
    VAR text_value = "Submitted"
    VAR _Filtered_Table =
        FILTER ( 'LogSheet', 'LogSheet'[Status] = text_value )
    VAR _Not_Submitted_EmpIDs =
        EXCEPT (
            VALUES ( 'LogSheet'[Emp_ID] ),
            CALCULATETABLE ( VALUES ( 'LogSheet'[Emp_ID] ), _Filtered_Table )
        )
    VAR _Result =
        COUNTROWS ( _Not_Submitted_EmpIDs )
    RETURN
        _Result
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 May 2023 11:08:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259502#M120478</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-30T11:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259522#M120479</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Thank you so much for the reply. I really appreciate you taking time out and providing the answer.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not sure what's the problem but it is not working correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, when I select two weeks together, it shows me&amp;nbsp;&lt;STRONG&gt;4 employees&amp;nbsp;&lt;/STRONG&gt;(but instead, it should only show 3 employees because "Leo" submitted Logsheet in both the weeks)&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;&lt;P&gt;Similarly, if I select all three weeks, then it shows&amp;nbsp;&lt;STRONG&gt;6 employees,&amp;nbsp;&lt;/STRONG&gt;which is wrong because total number of employees are only 4&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>Tue, 30 May 2023 11:16:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259522#M120479</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-30T11:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259712#M120491</link>
      <description>&lt;P&gt;I think the below works&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Missing = 
VAR Submitted = CALCULATETABLE(
	SUMMARIZE( 'LogSheet', 'LogSheet'[Emp_ID], 'LogSheet'[Week]),
	'LogSheet'[Status] = "Submitted"
)
VAR AllCombinations = CROSSJOIN(
	ALL('LogSheet'[Emp_ID]),
	ALLSELECTED( 'LogSheet'[Week])
)
VAR Missing = SELECTCOLUMNS( EXCEPT( AllCombinations, Submitted ), "Emp_ID", 'LogSheet'[Emp_ID] )
RETURN COUNTROWS( DISTINCT( Missing ) )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 May 2023 12:50:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3259712#M120491</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-30T12:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3260191#M120525</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This worked like a charm! Thank you soo much!&amp;nbsp;&lt;BR /&gt;I probably need to understand however that how is this working lol &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;but I will work on it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You used a Cross join however. That would badly affect the performance though, right? (especially in a larger dataset)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 17:39:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3260191#M120525</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-30T17:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create multiple dynamic tables of employees and counting unique employees from all of them</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3261294#M120601</link>
      <description>&lt;P&gt;The CROSSJOIN generates all possible combinations of employee and week, and that then allows comparison with the actual combinations where a log sheet was submitted. I think you would need a very large number of employees and a lot of years before you run into serious performance issues - each employee will only generate 52 entries per year.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 08:16:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-multiple-dynamic-tables-of-employees-and-counting/m-p/3261294#M120601</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-31T08:16:25Z</dc:date>
    </item>
  </channel>
</rss>

