<?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: COUNTIFS in DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081400#M107405</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;column = 
VAR _count =
COUNTROWS(
    FILTER(
       TableName,
       TableName[InvoiceType]="Item"
        &amp;amp;&amp;amp;TableName[Document]=EARLIER(TableName[Document])
        &amp;amp;&amp;amp;TableName[Item]=EARLIER(TableName[Item])
        &amp;amp;&amp;amp;TableName[City]=EARLIER(TableName[City])
    )
)
RETURN
IF(
   [InvoiceType]&amp;lt;&amp;gt;"Item",
   _count
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it worked like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 12:16:36 GMT</pubDate>
    <dc:creator>FreemanZ</dc:creator>
    <dc:date>2023-02-15T12:16:36Z</dc:date>
    <item>
      <title>COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079616#M107255</link>
      <description>&lt;P&gt;Can anybody please help with a DAX question. I have a report in Excel that counts the items that make up an invoice. I have atached a screenshot with the Excel formula highlighted. I am trying to recreate this report in Power BI but struggling with the DAX for this measure.&lt;img /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 13:55:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079616#M107255</guid>
      <dc:creator>bidataservices</dc:creator>
      <dc:date>2023-02-14T13:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079644#M107259</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;Item Count =&lt;BR /&gt;IF (&lt;BR /&gt;'Table'[Invoice Type] &amp;lt;&amp;gt; "Item",&lt;BR /&gt;COUNTROWS (&lt;BR /&gt;CALCULATETABLE (&lt;BR /&gt;'Table',&lt;BR /&gt;ALLEXCEPT ( 'Table', 'Table'[Document], 'Table'[Item], 'Table'[City] )&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:07:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079644#M107259</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-14T14:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079677#M107265</link>
      <description>&lt;P&gt;hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try like:&lt;/P&gt;&lt;DIV&gt;column =&lt;/DIV&gt;&lt;DIV&gt;VAR _count =&lt;/DIV&gt;&lt;DIV&gt;COUNTROWS(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; FILTER(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TableName,&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TableName[InvoiceType]="Item"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp;TableName[InvoiceType]=EARLIER(&lt;/SPAN&gt;&lt;SPAN&gt;TableName[InvoiceType]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp;TableName[Document]=EARLIER(&lt;/SPAN&gt;&lt;SPAN&gt;TableName[&lt;/SPAN&gt;&lt;SPAN&gt;Document&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp;TableName[&lt;/SPAN&gt;&lt;SPAN&gt;Item&lt;/SPAN&gt;&lt;SPAN&gt;]=EARLIER(&lt;/SPAN&gt;&lt;SPAN&gt;TableName[&lt;/SPAN&gt;&lt;SPAN&gt;Item&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp;TableName[City]=EARLIER(TableName[&lt;/SPAN&gt;&lt;SPAN&gt;City&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;/DIV&gt;&lt;DIV&gt;)&lt;/DIV&gt;&lt;DIV&gt;RETURN&lt;/DIV&gt;&lt;DIV&gt;IF(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;[InvoiceType]&amp;lt;&amp;gt;"Item",&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;_count&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:27:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079677#M107265</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-02-14T14:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079722#M107272</link>
      <description>&lt;P&gt;Have you considered pulling the data in and using Power Query to Group and Sum.&amp;nbsp; Steps would be in Power Query:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a Conditional Column that says if InvoiceType = Item then 1 else 0&lt;/LI&gt;&lt;LI&gt;Group by all the fields required and then Sum the conditional column and call it "Items"&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:47:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079722#M107272</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-14T14:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079746#M107277</link>
      <description>&lt;P&gt;You could consider creating a calculated column as well which then you could build a measure on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Items = 
VAR CountV = CALCULATE(COUNTA(Inv[InvoiceNo ]),FILTER('Inv','Inv'[Category] = EARLIER('Inv'[Category]) &amp;amp;&amp;amp; 'Inv'[Document Item] = EARLIER('Inv'[Document Item]) &amp;amp;&amp;amp; Inv[Subcategory]=EARLIER('Inv'[Subcategory])))
RETURN IF('Inv'[InvoiceType ]= "Invoice",CountV,BLANK())&lt;/LI-CODE&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;If you don't want to create a calculated column you could use the same formula to create a Summarize Table variable with SUMX to bring directly into a measure.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Items Total = 
VAR tTable = SUMMARIZE('Inv',Inv[Cutomer ],Inv[Category],Inv[Subcategory],Inv[Document Item],"Items",SUMX('Inv',IF(Inv[InvoiceType ]="Item",1,0)))
RETURN SUMX(tTable,[Items])&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:08:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3079746#M107277</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-14T15:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081181#M107394</link>
      <description>&lt;P&gt;Thanks, I have tried the calculated column and it is nearly there but not quite right. As you can see from the results below. It should be counting 3 items, as one of the locations is Manchester. How does the EARLIER function work?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 09:44:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081181#M107394</guid>
      <dc:creator>bidataservices</dc:creator>
      <dc:date>2023-02-15T09:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081400#M107405</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;column = 
VAR _count =
COUNTROWS(
    FILTER(
       TableName,
       TableName[InvoiceType]="Item"
        &amp;amp;&amp;amp;TableName[Document]=EARLIER(TableName[Document])
        &amp;amp;&amp;amp;TableName[Item]=EARLIER(TableName[Item])
        &amp;amp;&amp;amp;TableName[City]=EARLIER(TableName[City])
    )
)
RETURN
IF(
   [InvoiceType]&amp;lt;&amp;gt;"Item",
   _count
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it worked like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 12:16:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081400#M107405</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-02-15T12:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081412#M107406</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tried to verify tamerj's code, it worked like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Item Count = 
IF (
    TableName[InvoiceType] &amp;lt;&amp;gt; "Item",
    COUNTROWS (
        CALCULATETABLE (
            TableName,
            TableName[InvoiceType] = "Item",
            ALLEXCEPT ( TableName, TableName[Document], TableName[Item], TableName[City] )
        )
    )
)&lt;/LI-CODE&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;With CALCULATETABLE+ALLEXCEPT, the code is much more concise.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 12:23:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081412#M107406</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-02-15T12:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081494#M107415</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please refer to attached sample file with the solution&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Item Count = 
IF (
    'Table'[InvoiceType] &amp;lt;&amp;gt; "Item",
    COUNTROWS (
        CALCULATETABLE (
            'Table',
            'Table'[InvoiceType] = "Item",
            ALLEXCEPT ( 'Table', 'Table'[Document], 'Table'[Item], 'Table'[City] )
        )
    ) + 0
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:26:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3081494#M107415</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-15T13:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3083390#M107599</link>
      <description>&lt;P&gt;Thanks, that worked well.&lt;/P&gt;&lt;P&gt;What if I wanted to do a SUMIFS on sales?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 13:23:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3083390#M107599</guid>
      <dc:creator>bidataservices</dc:creator>
      <dc:date>2023-02-16T13:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3083404#M107601</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453051" data-lia-user-login="bidataservices" class="lia-mention lia-mention-user"&gt;bidataservices&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You mean like this?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Item Sales = 
IF (
    'Table'[InvoiceType] &amp;lt;&amp;gt; "Item",
    SUMX (
        CALCULATETABLE (
            'Table',
            'Table'[InvoiceType] = "Invoice",
            ALLEXCEPT ( 'Table', 'Table'[Document], 'Table'[Item], 'Table'[City] )
        ),
        'Table'[Sales]
    ) + 0
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 13:30:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3083404#M107601</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-16T13:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: COUNTIFS in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3087023#M107967</link>
      <description>&lt;P&gt;Just add another condition,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;amp;&amp;amp; Inv[City]=EARLIER('Inv'[City])&lt;/LI-CODE&gt;&lt;P&gt;You will want to add any conditions that make the record the same as the previous.&amp;nbsp; If my anyswer helped, please mark it.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 03:10:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNTIFS-in-DAX/m-p/3087023#M107967</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-20T03:10:22Z</dc:date>
    </item>
  </channel>
</rss>

