<?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: Cumulative total days active product in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4320016#M171502</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="324795" data-lia-user-login="Victornld2" class="lia-mention lia-mention-user"&gt;Victornld2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ensure your Calendar table has a relationship with fact_ActiveProducts[DateID]&lt;/P&gt;&lt;P&gt;Create measure:&lt;/P&gt;&lt;PRE&gt;AvgActiveDaysPerProduct =&lt;BR /&gt;VAR ActiveProducts =&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;VALUES(fact_ActiveProducts[ProductID]),&lt;BR /&gt;fact_ActiveProducts[DateID] &amp;lt;= MAX('Calendar'[Date]),&lt;BR /&gt;ISBLANK(fact_ActiveProducts[EndDate]) || fact_ActiveProducts[EndDate] &amp;gt;= MAX('Calendar'[Date])&lt;BR /&gt;)&lt;BR /&gt;VAR TotalActiveDays =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(fact_ActiveProducts[NumberOfActiveDays]),&lt;BR /&gt;VALUES(fact_ActiveProducts[ProductID]),&lt;BR /&gt;fact_ActiveProducts[DateID] &amp;lt;= MAX('Calendar'[Date]),&lt;BR /&gt;ISBLANK(fact_ActiveProducts[EndDate]) || fact_ActiveProducts[EndDate] &amp;gt;= MAX('Calendar'[Date])&lt;BR /&gt;)&lt;BR /&gt;VAR DistinctProducts =&lt;BR /&gt;COUNTROWS(ActiveProducts)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;DistinctProducts &amp;gt; 0,&lt;BR /&gt;TotalActiveDays / DistinctProducts,&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;/PRE&gt;&lt;PRE&gt;AvgActiveDaysPerProductByMonth =&lt;BR /&gt;AVERAGEX(&lt;BR /&gt;VALUES('Calendar'[Date]),&lt;BR /&gt;[AvgActiveDaysPerProduct]&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;Add Calendar[Month] or Calendar[Date] to your visual.&lt;BR /&gt;Use [AvgActiveDaysPerProduct] or [AvgActiveDaysPerProductByMonth] as the value field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-unicode-emoji" title=":love_letter:"&gt;💌&lt;/span&gt; If this helped, a Kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; or Solution mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; would be great! &lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/STRONG&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Kedar&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/kedar-pande" target="_blank" rel="noopener"&gt;Connect on LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 16:07:43 GMT</pubDate>
    <dc:creator>Kedar_Pande</dc:creator>
    <dc:date>2024-12-09T16:07:43Z</dc:date>
    <item>
      <title>Cumulative total days active product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4319878#M171495</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Been struggeling with this challenge:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Per month, I need to see the average of active days per product.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 product gets active on 1-jan-2024, and gets deactivated on 1-oct-2024.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So on 10-jan-2024&amp;nbsp;the average of active days = 10,&amp;nbsp;on 30-9-2024, the average of active days&amp;nbsp; = 274. On 1-10-2024 its NULL for this product.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is for 1 product, but it needs to aggregate for all products active on that day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the convenience I mad a fact table (fact_ActiveProducts) with 1 row per product per active day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;fact_ActiveProducts, columns:&lt;/P&gt;&lt;P&gt;ProductID&lt;/P&gt;&lt;P&gt;,DateID (related with Calendar table)&lt;/P&gt;&lt;P&gt;,BeginDate (date format)&lt;/P&gt;&lt;P&gt;,EndDate (dateformat) (can be empty when still active).&amp;nbsp;&lt;/P&gt;&lt;P&gt;,NumberOfActiveDays (1, a hard number 1 on each row to easy SUM the column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anybody got suggestions? The usual ways to calculate a rolling sum of cumulative total still counts the days of products after they where deactivated. And after the date that they are deactivated, they shouldn't be counted anymore for those dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I get the total count of days per row, I can divide it by a distinctcount of products active on that day.&lt;/P&gt;&lt;P&gt;The next step is to create an average by month, or get the value of the maxdate for the selected month.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 15:21:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4319878#M171495</guid>
      <dc:creator>Victornld2</dc:creator>
      <dc:date>2024-12-09T15:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative total days active product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4320016#M171502</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="324795" data-lia-user-login="Victornld2" class="lia-mention lia-mention-user"&gt;Victornld2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ensure your Calendar table has a relationship with fact_ActiveProducts[DateID]&lt;/P&gt;&lt;P&gt;Create measure:&lt;/P&gt;&lt;PRE&gt;AvgActiveDaysPerProduct =&lt;BR /&gt;VAR ActiveProducts =&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;VALUES(fact_ActiveProducts[ProductID]),&lt;BR /&gt;fact_ActiveProducts[DateID] &amp;lt;= MAX('Calendar'[Date]),&lt;BR /&gt;ISBLANK(fact_ActiveProducts[EndDate]) || fact_ActiveProducts[EndDate] &amp;gt;= MAX('Calendar'[Date])&lt;BR /&gt;)&lt;BR /&gt;VAR TotalActiveDays =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(fact_ActiveProducts[NumberOfActiveDays]),&lt;BR /&gt;VALUES(fact_ActiveProducts[ProductID]),&lt;BR /&gt;fact_ActiveProducts[DateID] &amp;lt;= MAX('Calendar'[Date]),&lt;BR /&gt;ISBLANK(fact_ActiveProducts[EndDate]) || fact_ActiveProducts[EndDate] &amp;gt;= MAX('Calendar'[Date])&lt;BR /&gt;)&lt;BR /&gt;VAR DistinctProducts =&lt;BR /&gt;COUNTROWS(ActiveProducts)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;DistinctProducts &amp;gt; 0,&lt;BR /&gt;TotalActiveDays / DistinctProducts,&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;/PRE&gt;&lt;PRE&gt;AvgActiveDaysPerProductByMonth =&lt;BR /&gt;AVERAGEX(&lt;BR /&gt;VALUES('Calendar'[Date]),&lt;BR /&gt;[AvgActiveDaysPerProduct]&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;Add Calendar[Month] or Calendar[Date] to your visual.&lt;BR /&gt;Use [AvgActiveDaysPerProduct] or [AvgActiveDaysPerProductByMonth] as the value field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-unicode-emoji" title=":love_letter:"&gt;💌&lt;/span&gt; If this helped, a Kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; or Solution mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; would be great! &lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/STRONG&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Kedar&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/kedar-pande" target="_blank" rel="noopener"&gt;Connect on LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 16:07:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4320016#M171502</guid>
      <dc:creator>Kedar_Pande</dc:creator>
      <dc:date>2024-12-09T16:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative total days active product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4320767#M171546</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="324795" data-lia-user-login="Victornld2" class="lia-mention lia-mention-user"&gt;Victornld2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether the advice given by&amp;nbsp;Kedar_Pande&amp;nbsp;has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 03:15:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4320767#M171546</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-10T03:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative total days active product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4334995#M172118</link>
      <description>&lt;P&gt;Apologies for the late reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The advised solution didn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately we came up with the following solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Average active days per product =&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR &lt;/SPAN&gt;&lt;SPAN&gt;_result&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;( fact_ActiveProducts[ProductID] ) , &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;( fact_ActiveProducts&lt;/SPAN&gt;&lt;SPAN&gt;[NumberOfProductsStarting]&lt;/SPAN&gt;&lt;SPAN&gt; ) , &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; &lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;( Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; ) , &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;( Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; ) &amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;( fact_ActiveProducts&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; ) , &lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;( Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; ) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&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; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;_result&lt;/SPAN&gt;&lt;SPAN&gt; , &lt;/SPAN&gt;&lt;SPAN&gt;[Count of active products]&lt;/SPAN&gt;&lt;SPAN&gt; , &lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;() )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, my apologies for the late reaction but thank you very much for the effort and suggested advice!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 11:49:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-total-days-active-product/m-p/4334995#M172118</guid>
      <dc:creator>Victornld2</dc:creator>
      <dc:date>2024-12-18T11:49:48Z</dc:date>
    </item>
  </channel>
</rss>

