<?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: Count with condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924486#M96001</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476206" data-lia-user-login="Rth" class="lia-mention lia-mention-user"&gt;Rth&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try below code:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;m =
VAR _calc =
    FILTER (
        SUMMARIZE (
            'Table (5)',
            'Table (5)'[Name of Project],
            "_SUM", SUM ( 'Table (5)'[Column1] )
        ),
        [_SUM] &amp;gt;= 20
    )
RETURN
    COUNTROWS ( _calc )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2022 12:58:07 GMT</pubDate>
    <dc:creator>Samarth_18</dc:creator>
    <dc:date>2022-11-23T12:58:07Z</dc:date>
    <item>
      <title>Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924287#M95987</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi everyone, would anyone be able to help with a DAX calculation for the following?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a table including Name of the Project (projects are recurring) and Amount of Hours as columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now I would like to create a Measure that determines the number of projects that have more than 20 hours.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I already have a Measure&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;that determines the number of projects:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Anzahl Projekte 2022 = DISTINCTCOUNT(CATS_Buchungen[Auftragsname]).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do I add the condition that only projects over 20 hours are Counted? I have tried so Mandy things, but nothing worked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 11:17:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924287#M95987</guid>
      <dc:creator>Rth</dc:creator>
      <dc:date>2022-11-23T11:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924384#M95993</link>
      <description>&lt;DIV&gt;Try to create a measure with the code below:&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;Project20Plus =&lt;DIV&gt;&amp;nbsp; &amp;nbsp; COUNTROWS(&lt;DIV&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; FILTER(&lt;DIV&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; ALL(CATS_Buchungen),&lt;DIV&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;CATS_Buchungen[HoursColumn]&amp;gt;20&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Nov 2022 12:01:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924384#M95993</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-11-23T12:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924445#M95998</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your response.&lt;/P&gt;&lt;P&gt;I think I did not express myself well enough. I attachted an example:&lt;/P&gt;&lt;P&gt;The table's name is "Table".&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regarding your code:&lt;/P&gt;&lt;P&gt;I used DISTINCTCOUNT instead of COUNTROWS because I would like to count the distinct number of projects. But the code still did not work..&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 12:40:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924445#M95998</guid>
      <dc:creator>Rth</dc:creator>
      <dc:date>2022-11-23T12:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924486#M96001</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476206" data-lia-user-login="Rth" class="lia-mention lia-mention-user"&gt;Rth&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try below code:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;m =
VAR _calc =
    FILTER (
        SUMMARIZE (
            'Table (5)',
            'Table (5)'[Name of Project],
            "_SUM", SUM ( 'Table (5)'[Column1] )
        ),
        [_SUM] &amp;gt;= 20
    )
RETURN
    COUNTROWS ( _calc )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 12:58:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924486#M96001</guid>
      <dc:creator>Samarth_18</dc:creator>
      <dc:date>2022-11-23T12:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924836#M96028</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution of&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="312802" data-lia-user-login="Samarth_18" class="lia-mention lia-mention-user"&gt;Samarth_18&lt;/a&gt;&amp;nbsp;works fine and you don't need to do a distinct count, since because of summarize, your project we'll be only one time with the total time of each project.&lt;/P&gt;
&lt;P&gt;If i take the same formula as he proposed :&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;SPAN&gt;Count of Project with more than 20h = &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; TableTemp = &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZECOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;( 'Table Name'[ID Project] , &lt;/SPAN&gt;&lt;SPAN&gt;"Tot Hours Project"&lt;/SPAN&gt;&lt;SPAN&gt; , &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;( 'Table Name'[Time spent column] ) ) ,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; [Tot Hours Project] &amp;gt; 20&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;) //This is the filter on the column created above&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COUNTROWS&lt;/SPAN&gt;&lt;SPAN&gt;( TableTemp ) //Counting the remaining rows after filtering gives us the result&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;In this formula :&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;1/ SUMMARIZE creates a table with a unique list of project and their respective total time&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;2/ FILTER applies on the invisible column just created in SUMMARIZE, in my example named&amp;nbsp; "Tot Hours Project". This name is used 2 times, to create the column and its values, and then to filter.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;3/ Finally counting the remaing rows in that table gives us expected result.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Hope it makes things more clear...&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Let us know&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Nov 2022 15:19:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924836#M96028</guid>
      <dc:creator>AilleryO</dc:creator>
      <dc:date>2022-11-23T15:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924943#M96037</link>
      <description>&lt;P&gt;Aha, then try this&lt;/P&gt;&lt;P&gt;Project20Plus =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNTROWS(&amp;nbsp; &amp;nbsp;DISTINCT(CATS_Buchungen[Project])&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL(CATS_Buchungen),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CATS_Buchungen[HoursColumn]&amp;gt;20&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 15:54:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2924943#M96037</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-11-23T15:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Count with condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2937987#M96925</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476206" data-lia-user-login="Rth" class="lia-mention lia-mention-user"&gt;Rth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you getting your problems solved ?&amp;nbsp;If it has been solved, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Ailsa Tao&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 07:55:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-with-condition/m-p/2937987#M96925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-30T07:55:58Z</dc:date>
    </item>
  </channel>
</rss>

