<?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 calculated column with count of distinct items per date &amp;amp; location? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3702402#M143992</link>
    <description>&lt;P&gt;Try this syntax&lt;/P&gt;&lt;P&gt;Calculate(distinctcount ( table, sl no), allexcept( table, site, date))&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2024 21:09:45 GMT</pubDate>
    <dc:creator>Rupak_bi</dc:creator>
    <dc:date>2024-02-15T21:09:45Z</dc:date>
    <item>
      <title>How to create calculated column with count of distinct items per date &amp; location?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3702231#M143987</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add a calculated column to my dataset that counts the number of distinct serial numbers produced per day, and per site.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This value will be used as a global filter in the PBIX file, so it'll only show data for days where there are greater than X serial numbers.&lt;/LI&gt;&lt;LI&gt;It needs to be a filter, because different teams have different min values they want to use.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a decent amount of Power BI/DAX experience. This seems conceptually simple, but I'm WAY overthinking it, and that's led me down many PBI Community/stackoverflow rabbit holes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; A nudge in the right direction would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I need to do a group by with just the columns I want to aggregate on. This might be the right configuration for the groupby:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;GROUPBY(Append2, Append2[Date], Append2[Site], "SN Count Per Day and Site", COUNTX(CURRENTGROUP(), DISTINCTCOUNT(Append2[Serial Number] )))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run that in the DAX Query View, it returns a table with 3 columns - date, site, SN count per day and site.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;[Date]&lt;/TD&gt;&lt;TD&gt;[Site]&lt;/TD&gt;&lt;TD&gt;[SN Count Per Day and Site]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thu Dec 01 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thu Dec 01 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Fri Dec 02 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Sat Dec 03 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tue Dec 06 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #2&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tue Dec 06 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wed Dec 07 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #2&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wed Dec 07 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thu Dec 08 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #1&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thu Dec 08 2022&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Site #2&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's the values in the SN Count Per Day and Site column that I want to include in the new calculated column in my dataset. So for all twenty rows in the data set with a date of 12/1/2022 and site # of 1, they should all show the value 20.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Question #1&lt;/STRONG&gt;:&amp;nbsp;How do I do that? Is a JOIN the right approach? I've never done that before in DAX, but have in SQL. But that seems overly complex, so I think there's a concept I'm missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question #2&lt;/STRONG&gt;: For the GROUPBY -&amp;nbsp;I'm confused on why I need to use COUNTX to aggregate here, but that's what appeared to work when I was playing around with the formula. The aggregation I want is the distinct # of serial numbers produced for that date/site combo. I believe COUNTX here would be the # of rows with a given date/site combo - which could mean duplicate serial numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I read the awesome FAQ before posting, and did my best on brevity)&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 19:35:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3702231#M143987</guid>
      <dc:creator>Data_Scrubber</dc:creator>
      <dc:date>2024-02-15T19:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create calculated column with count of distinct items per date &amp; location?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3702402#M143992</link>
      <description>&lt;P&gt;Try this syntax&lt;/P&gt;&lt;P&gt;Calculate(distinctcount ( table, sl no), allexcept( table, site, date))&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 21:09:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3702402#M143992</guid>
      <dc:creator>Rupak_bi</dc:creator>
      <dc:date>2024-02-15T21:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create calculated column with count of distinct items per date &amp; location?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3708926#M144307</link>
      <description>&lt;P&gt;Hi Rupak,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I greatly appreciate your prompt reply - sorry I was slow to respond.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That worked perfectly. I'm a little confused by how ALLEXCEPT works, but I think I just need to go process more examples for it to sink in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 19:36:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-create-calculated-column-with-count-of-distinct-items-per/m-p/3708926#M144307</guid>
      <dc:creator>Data_Scrubber</dc:creator>
      <dc:date>2024-02-19T19:36:28Z</dc:date>
    </item>
  </channel>
</rss>

