<?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 days with filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4257633#M168692</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="348409" data-lia-user-login="Sperling" class="lia-mention lia-mention-user"&gt;Sperling&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached the demo file. Does it make sense to you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = 
VAR _item = SELECTEDVALUE(DimItem[DW_SK_Item])
VAR _min_date = CALCULATE(MAX(DimDate[Date]), DimDeadstock[Deadstock] = "No", REMOVEFILTERS(DimDate[Date]))

RETURN
CALCULATE( COUNT(FactInventory[DW_SK_Date]), 
FILTER(ALL(FactInventory), FactInventory[DW_SK_Item] = _item &amp;amp;&amp;amp; RELATED(DimDate[Date]) &amp;gt; _min_date))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2024 07:53:14 GMT</pubDate>
    <dc:creator>isjoycewang</dc:creator>
    <dc:date>2024-10-25T07:53:14Z</dc:date>
    <item>
      <title>Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4252663#M168428</link>
      <description>&lt;P&gt;I have a fact table with items and a dummy for whether the item is deadstock or not.&lt;/P&gt;&lt;P&gt;This is stamped on the items each day, so we can see the history of the items we have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fact table is connected to our item dimension, the date dimension and the deadstock time dependent dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a measure that calculates how long the item has been deadstock IF it currently is deadstock.&lt;/P&gt;&lt;P&gt;I've approached this in a few different ways without luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an image of a random item that is currently marked as deadstock:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The value I'm interested in here is 9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured it was as simple as:&lt;/P&gt;&lt;P&gt;1. finding the max date where Deadstock = No&lt;/P&gt;&lt;P&gt;2. finding the max date where Deadstock = Yes&lt;/P&gt;&lt;P&gt;3. making sure the measure only calculates for cases where Deadstock on today() - 1 = Yes (important)&lt;/P&gt;&lt;P&gt;4. and then finally counting the rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't just count rows where Deadstock = Yes, since I don't want to include old periods where it was Deadstock, only the current period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It has proved more difficult than anticipated, so&amp;nbsp;I'm open to suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 13:35:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4252663#M168428</guid>
      <dc:creator>Sperling</dc:creator>
      <dc:date>2024-10-22T13:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4253117#M168457</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information. Do not include anything that is unrelated to the issue or question. &lt;BR /&gt;&lt;BR /&gt;Need help uploading data? &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 21:07:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4253117#M168457</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-10-22T21:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4255776#M168588</link>
      <description>&lt;P&gt;I've made a sample here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1fDsLFh9XHxx2HZ6ZfjjV6HbYOA8J28t6/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1fDsLFh9XHxx2HZ6ZfjjV6HbYOA8J28t6/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table on the left is the type of table I'm interested in making, where the day count should be a measure next to inventory.&lt;/P&gt;&lt;P&gt;Table in the middle is an example of an item, where the deadstock day count should be 13 (days with Yes in Deadstock column).&lt;/P&gt;&lt;P&gt;Table on the right is another example, where we have two periods with Deadstock = Yes. The count should only count if the current status is Deadstock = Yes, and should only count the current period, which means from the 13th to the 23rd = 11 days.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 07:33:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4255776#M168588</guid>
      <dc:creator>Sperling</dc:creator>
      <dc:date>2024-10-24T07:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4257633#M168692</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="348409" data-lia-user-login="Sperling" class="lia-mention lia-mention-user"&gt;Sperling&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached the demo file. Does it make sense to you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = 
VAR _item = SELECTEDVALUE(DimItem[DW_SK_Item])
VAR _min_date = CALCULATE(MAX(DimDate[Date]), DimDeadstock[Deadstock] = "No", REMOVEFILTERS(DimDate[Date]))

RETURN
CALCULATE( COUNT(FactInventory[DW_SK_Date]), 
FILTER(ALL(FactInventory), FactInventory[DW_SK_Item] = _item &amp;amp;&amp;amp; RELATED(DimDate[Date]) &amp;gt; _min_date))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 07:53:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4257633#M168692</guid>
      <dc:creator>isjoycewang</dc:creator>
      <dc:date>2024-10-25T07:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4257899#M168703</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="613640" data-lia-user-login="isjoycewang" class="lia-mention lia-mention-user"&gt;isjoycewang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate the response! I attempted to use it in my actual model and realized I made a mistake in the sample dataset.&lt;/P&gt;&lt;P&gt;PBI applied both cross-filter direction to the date dimension, which it wasn't supposed to. After I changed it to single cross-filter direction, the measure was blank.&lt;/P&gt;&lt;P&gt;I've attached the file again here, but in your model you can also just change the cross-filter setting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1UO5JbDorQBR-LbaoJD333yLvC02eKF-5/view?usp=drive_link" target="_blank"&gt;https://drive.google.com/file/d/1UO5JbDorQBR-LbaoJD333yLvC02eKF-5/view?usp=drive_link&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 10:18:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4257899#M168703</guid>
      <dc:creator>Sperling</dc:creator>
      <dc:date>2024-10-25T10:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4258260#M168721</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 14:35:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-days-with-filters/m-p/4258260#M168721</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-10-25T14:35:34Z</dc:date>
    </item>
  </channel>
</rss>

