<?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 row on condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3351926#M125874</link>
    <description>&lt;P&gt;Nice. That is really close to what I wrote (good on you for accounting for blank), I wonder why yours worked and mine didn't!&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2023 21:13:02 GMT</pubDate>
    <dc:creator>AnthonyGenovese</dc:creator>
    <dc:date>2023-07-26T21:13:02Z</dc:date>
    <item>
      <title>count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341591#M125421</link>
      <description>&lt;P&gt;I'm having some difficulties with a DAX query. I have this table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Name (string)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;In use (date)&lt;/TD&gt;&lt;TD&gt;Out of use (date)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Car 1&lt;/TD&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;06/05/2021&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Car 2&lt;/TD&gt;&lt;TD&gt;01/06/2020&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Car 3&lt;/TD&gt;&lt;TD&gt;05/09/2021&lt;/TD&gt;&lt;TD&gt;04/08/2030&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with cars and a date table. I want to create a measure that I can use to draw a Column chart. On the X-axis we have the quarters, on the y-axis the total numbers of cars that are in use on the last day of the quarter.&lt;/P&gt;&lt;P&gt;This is what I have but it does not seem to work correctly. I'm struggling with the today()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Active assets = CALCULATE( COUNTROWS('Fleet'), 'Fleet'[In use ] &amp;lt;= today() &amp;amp;&amp;amp; 'Fleet'[Out of use] &amp;gt;= today() )​&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 20 Jul 2023 18:06:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341591#M125421</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-20T18:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341619#M125424</link>
      <description>&lt;P&gt;What isn't working about it? Can you provide more details?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 18:21:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341619#M125424</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-20T18:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341622#M125425</link>
      <description>&lt;P&gt;The result is not correct, it seems like I got only the newly active assets in the period, not the accumulated active assets&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 18:22:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341622#M125425</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-20T18:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341625#M125427</link>
      <description>&lt;P&gt;I don't understand what you mean. With the details you already provided, what rows are being counted and what rows are being excluded?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 18:24:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341625#M125427</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-20T18:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341772#M125445</link>
      <description>&lt;P&gt;I'm starting to understand what goes wrong. In my model I have a relationship between the In use column and the date column of my datetime tabel. So when I create a barchart with the data on the x-axis, the data is automatically filtered. I only get to see the number of cars where the In Use data is the same as the X-axis label. I don't want that, for every label on the x-axis, I want to visualize the number of cars that are active (meaning a-axis label is between In Use and Out Of Use)&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:14:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341772#M125445</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-20T20:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341779#M125446</link>
      <description>&lt;P&gt;What about something like&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;CALCULATE( COUNTROWS('Fleet'), ALL(DateTable), 'Fleet'[In use ] &amp;lt;= today() &amp;amp;&amp;amp; 'Fleet'[Out of use] &amp;gt;= today() )​&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:17:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341779#M125446</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-20T20:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341788#M125448</link>
      <description>&lt;P&gt;Now I have a constant value over the entire timerange, I suppose it's not filtering at all anymore. I don't understand the today(). It shouldn't be today(), it should be the month, year, ... of the x-axis&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:25:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341788#M125448</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-20T20:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341792#M125449</link>
      <description>&lt;P&gt;Then something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var dateFilter=selectedvalue(dateTable[date])&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var result= CALCULATE( COUNTROWS('Fleet'), ALL(DateTable), 'Fleet'[In use ] &amp;lt;= dateFilter &amp;amp;&amp;amp; 'Fleet'[Out of use] &amp;gt;= dateFilter)​&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;return result&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:28:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341792#M125449</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-20T20:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341819#M125450</link>
      <description>&lt;P&gt;This doesn't return anything at all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:40:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341819#M125450</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-20T20:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341830#M125451</link>
      <description>&lt;P&gt;You will need to provide more concrete details then, showing relationships, table metadata, table data, the chart you are using, and how it is configured. The last code I sent you takes a look at the xaxis, then counts the rows for the fleet table by first removing the xaxis filter, but then applying it to the two columns.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 20:45:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3341830#M125451</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-20T20:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3350506#M125805</link>
      <description>&lt;P&gt;this solved it:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Active assets = 
var endDate = MAX(DateTime[Date])

var result = 
CALCULATE(
    COUNTROWS('fleet'),
    REMOVEFILTERS('DateTime'),
    'fleet'[in use] &amp;lt;= endDate,
    'fleet'[out of use] &amp;gt; endDate
    ||
    ISBLANK('fleet'[out of use])
)

return result&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Jul 2023 08:38:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3350506#M125805</guid>
      <dc:creator>brechtt</dc:creator>
      <dc:date>2023-07-26T08:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: count row on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3351926#M125874</link>
      <description>&lt;P&gt;Nice. That is really close to what I wrote (good on you for accounting for blank), I wonder why yours worked and mine didn't!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 21:13:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/count-row-on-condition/m-p/3351926#M125874</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-26T21:13:02Z</dc:date>
    </item>
  </channel>
</rss>

