<?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 query countdistinct in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/912728#M8764</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you for your solution, it's working with powerbi but i need it on SSRS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;EVALUATE 
VAR InternalTable = 
    SUMMARIZECOLUMNS( 
        'orders'[vendor],
        "Total",CALCULATE(SUM('Orders'[Price]),
               'orders'[OrderBilling] &amp;gt;= VALUE ( "01/01/2019" ),
               'orders'[OrderBilling] &amp;lt;= VALUE ( "10/01/2019" ))
            +CALCULATE(SUM('Orders'[Price]]),
               'orders'[OrderBilling] &amp;gt; VALUE ( "10/01/2019" ),
                'orders'[OrderTaken]   &amp;lt;= VALUE ("10/01/2019" ))
            )

Return
GROUPBY(
    InternalTable,
    'orders'[vendor],
    "Total_Sales",SUMX(CURRENTGROUP(),[Total]),
    "Current_Clients",COUNTX(CURRENTGROUP(),[Total])
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2020 17:39:40 GMT</pubDate>
    <dc:creator>calimero48</dc:creator>
    <dc:date>2020-01-27T17:39:40Z</dc:date>
    <item>
      <title>DAX query countdistinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/901972#M8265</link>
      <description>&lt;DIV class="post-text"&gt;&lt;P&gt;I want to countdistinct from the following in DAX.&lt;/P&gt;&lt;P&gt;I have a table orders with the columns and sample as:&lt;/P&gt;&lt;PRE&gt;OrderNumber  Customer Vendor   OrderTaken   OrderDelivery   OrderBilling    Qty   Price
1              1        V1     2018/12/01    2019/01/10     2019/01/10       1      1
2              10       V1     2019/01/04    2019/01/07     2019/01/07       1      1
3              100      V2     2019/01/02    2019/01/04     2019/01/06       1      1
4              100      V2     2019/01/02    2019/07/01     2019/07/01       1      1
(              10       V1     2020/01/04    2020/01/07     2020/01/07       1      1&lt;/PRE&gt;&lt;P&gt;Date Format is yyyy/MM/dd&lt;/P&gt;&lt;P&gt;I want to count the price and count the number of distinct customer for each vendor from the 1st January to the 10th January billed and the ordertaken before the 10th Januray that are not billed.&lt;/P&gt;&lt;P&gt;I am able to calculate the sum for the price, one for billed order and one for ordertaken but I need to count the number of distinct client even if there is an order billed and one not yet billed.&lt;/P&gt;&lt;P&gt;For the sum I have done:&lt;/P&gt;&lt;PRE&gt;EVALUATE
SUMMARIZECOLUMNS (
    'orders'[vendor],
    "Billed", CALCULATE (
        SUM ( 'Orders'[Price] ),
        'orders'[OrderBilling] &amp;gt;= VALUE ( "01/01/2019" ),
        'orders'[OrderBilling] &amp;lt;= VALUE ( "10/01/2019" )
    ),
    "NotBilled", CALCULATE (
        SUM ( 'ZBW00001'[CANET(-DATION)] ),
        'orders'[OrderBilling] &amp;gt; VALUE ( "20190110" ),
        'orders'[OrderTaken]   &amp;lt;= VALUE ( "20190110" )
    )
)&lt;/PRE&gt;&lt;P&gt;I got as result&lt;/P&gt;&lt;PRE&gt;Vendor     Billed        NotBilled
V1            2
V2            1              1&lt;/PRE&gt;&lt;P&gt;The number of distinct customer is 2 (Vendor).&lt;/P&gt;&lt;P&gt;I do not see how can I get it. If somebody can help me. Thanks in advance&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Jan 2020 10:03:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/901972#M8265</guid>
      <dc:creator>calimero48</dc:creator>
      <dc:date>2020-01-16T10:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query countdistinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/903305#M8338</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="57595" data-lia-user-login="calimero48" class="lia-mention lia-mention-user"&gt;calimero48&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;simple DISTINCTCOUNT isn't ok for you?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;The number of distinct customer = 
CALCULATE(DISTINCTCOUNT('orders'[Vendor]);ALL('orders'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 10:51:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/903305#M8338</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2020-01-17T10:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query countdistinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/904076#M8394</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help but it's not so simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The desired output is to have the number of distinct customer from the two periods:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'orders'[OrderBilling] &amp;gt;= VALUE ( "01/01/2019" ), 'orders'[OrderBilling] &amp;lt;= VALUE ( "10/01/2019" ) and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'orders'[OrderBilling] &amp;gt; VALUE ( "20190110" ), 'orders'[OrderTaken] &amp;lt;= VALUE ( "20190110" )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I used the same method as the SUM, i will have&lt;/P&gt;&lt;P&gt;Vendor NbcustomerBilled NbCustomerNotBilled&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the number of distinct user will be 4 that is not the truth, should be 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Vendor NbCustomerDistinct SumSales&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 2&amp;nbsp; ( Two customers 1 and 10)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 2 ( Only one customer 100 )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 20:00:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/904076#M8394</guid>
      <dc:creator>calimero48</dc:creator>
      <dc:date>2020-01-18T20:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query countdistinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/904095#M8399</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="57595" data-lia-user-login="calimero48" class="lia-mention lia-mention-user"&gt;calimero48&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thats what I have done:&lt;/P&gt;&lt;P&gt;1. create a table&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Table 2 = 
UNION(
FILTER(ALL('Table');
            'Table'[OrderBilling]&amp;gt;=DATE(2019;01;01) &amp;amp;&amp;amp; 'Table'[OrderBilling]&amp;lt;=DATE(2019;01;10));
FILTER(ALL('Table');
            'Table'[OrderBilling]&amp;gt;DATE(2019;01;10) &amp;amp;&amp;amp; 'Table'[OrderTaken]&amp;lt;=DATE(2019;01;10)
)
)&lt;/LI-CODE&gt;&lt;P&gt;then add to visual a column 'Table2'[Customer] and set aggregation as Count(Distinct) in visual settings. This is Number of customers&lt;/P&gt;&lt;P&gt;then&amp;nbsp;add to visual a column 'Table2'[Customer] and set aggregation as Count in visual settings. This is Sum of sales by customers&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;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://linkedin.com/in/alekseizhukov" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 22:55:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/904095#M8399</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2020-01-18T22:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query countdistinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/912728#M8764</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you for your solution, it's working with powerbi but i need it on SSRS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;EVALUATE 
VAR InternalTable = 
    SUMMARIZECOLUMNS( 
        'orders'[vendor],
        "Total",CALCULATE(SUM('Orders'[Price]),
               'orders'[OrderBilling] &amp;gt;= VALUE ( "01/01/2019" ),
               'orders'[OrderBilling] &amp;lt;= VALUE ( "10/01/2019" ))
            +CALCULATE(SUM('Orders'[Price]]),
               'orders'[OrderBilling] &amp;gt; VALUE ( "10/01/2019" ),
                'orders'[OrderTaken]   &amp;lt;= VALUE ("10/01/2019" ))
            )

Return
GROUPBY(
    InternalTable,
    'orders'[vendor],
    "Total_Sales",SUMX(CURRENTGROUP(),[Total]),
    "Current_Clients",COUNTX(CURRENTGROUP(),[Total])
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 17:39:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-query-countdistinct/m-p/912728#M8764</guid>
      <dc:creator>calimero48</dc:creator>
      <dc:date>2020-01-27T17:39:40Z</dc:date>
    </item>
  </channel>
</rss>

