<?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: DAX - Filter Multiple Conditions - Not Counting Rows Correctly in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3627039#M140262</link>
    <description>&lt;P&gt;ahh, nice catch. I will try that when I get some time tonight and respond. That makes sense, I am sure you're correct.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 15:19:58 GMT</pubDate>
    <dc:creator>DH3612</dc:creator>
    <dc:date>2024-01-09T15:19:58Z</dc:date>
    <item>
      <title>DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3617756#M139868</link>
      <description>&lt;P&gt;Hey all. Hope you can help with this one. Ive tried and tried and not really got anyweher useful. Even tried ChatGPT but after that failed I reverted back to my original doc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a PBI Desktop file. It contains the following Tables/Columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Staffmaster (Start Date, End Date, Unique ID, ELT) This is the main data tablewith all employees on it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;EOM (End of Month) This is a table with just the end date of every month for the last 30 years&lt;/P&gt;&lt;P&gt;Date (Date, Month, year) Date Table and noted as such in PBI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently use this code to count my active employees at each month end. This then goes into a column chart showing how many employees on each month end date.&lt;/P&gt;&lt;LI-CODE lang="css"&gt;EmployeeCount = 
CALCULATE(
    COUNTROWS(RELATEDTABLE(Staffmaster)),
    FILTER(
        Staffmaster,
        Staffmaster[Start Date] &amp;lt;= EARLIER(EOM[End of Month]) &amp;amp;&amp;amp;
        (ISBLANK(Staffmaster[End Date]) || Staffmaster[End Date] &amp;gt; EARLIER(EOM[End of Month]))
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a way to have an additional filter condition on the ELT Column. Using a slicer on the ELT column. Basically break it down by Business Areas. But everything I have tried has failed. Most of which has been along the lines of the following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;ActiveEmployeeCount =
VAR SelectedELTValues = VALUES(Staffmaster[ELT])

RETURN
CALCULATE(
    COUNTROWS(Staffmaster),
    FILTER(
        Staffmaster,
        Staffmaster[Start Date] &amp;lt;= MAX(EOM[End of Month]) &amp;amp;&amp;amp;
        (ISBLANK(Staffmaster[End Date]) || Staffmaster[End Date] &amp;gt; MIN('EOM'[End of Month])) &amp;amp;&amp;amp;
        Staffmaster[ELT] IN SelectedELTValues
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However this just seems to count all rows in the staffmaster table without filtering. Variations I tried seem to either count all rows, or count a singular value of 1 for each month end.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions for where I am going wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 11:47:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3617756#M139868</guid>
      <dc:creator>DH3612</dc:creator>
      <dc:date>2024-01-05T11:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3617982#M139870</link>
      <description>&lt;P&gt;OK, I have been trying again with this and still getting nowhere:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use the code as follows - with a name or Business Area hard coded, then it works perfect.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;EmployeeCount = 
CALCULATE(
  COUNTROWS(Staffmaster),
  FILTER(
    Staffmaster,
    Staffmaster[Start Date] &amp;lt;= EOMONTH(EOM[End of Month], 0) &amp;amp;&amp;amp;
    (ISBLANK(Staffmaster[End Date]) || Staffmaster[End Date] &amp;gt; EOMONTH(EOM[End of Month], -1))
  ),
  Staffmaster[ELT] = "Bob Smith"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However if I change it to use a slicer dynamically as such. I get a value 1 for every month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;EmployeeCount = 
CALCULATE(
  COUNTROWS(Staffmaster),
  FILTER(
    Staffmaster,
    Staffmaster[Start Date] &amp;lt;= EOMONTH(EOM[End of Month], 0) &amp;amp;&amp;amp;
    (ISBLANK(Staffmaster[End Date]) || Staffmaster[End Date] &amp;gt; EOMONTH(EOM[End of Month], -1))
  ),
  Staffmaster[ELT] = SELECTEDVALUE(Staffmaster[ELT])
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Jan 2024 14:01:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3617982#M139870</guid>
      <dc:creator>DH3612</dc:creator>
      <dc:date>2024-01-05T14:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3618062#M139872</link>
      <description>&lt;P&gt;You shouldn't have to add &lt;EM&gt;any&lt;/EM&gt; reference to dimension columns (in this case Staffmaster[ELT]) in your measure if you simply want to filter or slice. That's the concept of Power BI...&lt;BR /&gt;Have you tried taking out that logic?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 14:59:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3618062#M139872</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-01-05T14:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3618249#M139882</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic End of Month Employed Staff Calc is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;EmployeeCount = 
CALCULATE(
    COUNTROWS(RELATEDTABLE(Staffmaster)),
    FILTER(
        Staffmaster,
        Staffmaster[Start Date] &amp;lt;= EARLIER(EOM[End of Month]) &amp;amp;&amp;amp;
        (ISBLANK(Staffmaster[End Date]) || Staffmaster[End Date] &amp;gt; EARLIER(EOM[End of Month]))
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I add a slicer to the page, then select an ELT/Business Area then it does not affect the visual in any way. (It affects thers on the page bvut not the Employee Count). I just need a way to filter that result further by ELT.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 16:35:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3618249#M139882</guid>
      <dc:creator>DH3612</dc:creator>
      <dc:date>2024-01-05T16:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3622193#M140075</link>
      <description>&lt;P&gt;I am starting to suspect&amp;nbsp; you have added "EmployeeCount" as a computed column instead of as a measure. Computed column values are calculated at load, so will never work with slicers.&lt;BR /&gt;&lt;BR /&gt;I created a measure like below, and that works fine.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EmployeeCount = 
VAR sd = MAX(EOM[End of Month])
RETURN CALCULATE(
    COUNTROWS(Staffmaster)
    ,StaffMaster[Start Date]&amp;lt;=sd
    ,StaffMaster[End Date]&amp;gt;=sd || ISBLANK(StaffMaster[End Date])
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Jan 2024 11:02:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3622193#M140075</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-01-08T11:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: DAX - Filter Multiple Conditions - Not Counting Rows Correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3627039#M140262</link>
      <description>&lt;P&gt;ahh, nice catch. I will try that when I get some time tonight and respond. That makes sense, I am sure you're correct.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 15:19:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Filter-Multiple-Conditions-Not-Counting-Rows-Correctly/m-p/3627039#M140262</guid>
      <dc:creator>DH3612</dc:creator>
      <dc:date>2024-01-09T15:19:58Z</dc:date>
    </item>
  </channel>
</rss>

