<?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 Include only articles that have moved consecutively during selected months in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2130170#M48877</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is my first post here, as I have only recently started working with PBI (I'm coming from a Qlik world, but that might change). With that in mind, I hope that I'm able to formulate my needs as clear as possible.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, I have a problem that I've been stuck for quite some while now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H2&gt;Intro&lt;/H2&gt;&lt;P&gt;I want to analyze the average sales price development on a monthly basis. The requirements are 1) Calculate the average price per company, article, and year-month; then sum these values up (it's specific to our situation); 2) &lt;STRONG&gt;Only analyze articles that have moved consecutively during the time period that is selected by the user,&lt;/STRONG&gt; i.e. if I select year 2021 and months jan-sept, I need to dynamically include only articles that have moved at least once per month during 2021 jan-sept.&lt;/P&gt;&lt;H2&gt;&lt;BR /&gt;Month measures&lt;/H2&gt;&lt;P&gt;For this I first deciced to calculate how many months are available in total (with a minor tweak to remove the current month under certain conditions), a number that should depend only on the time selection:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I calculate the months that are available, accepting all filters:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, I create a new measure that is a straight comparison between above two measure, i.e. a boolean that I mean to use as a filter later:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far so good, in as much as these measures verifiably work.&amp;nbsp;&lt;/P&gt;&lt;H2&gt;&lt;BR /&gt;Article filter&lt;/H2&gt;&lt;P&gt;Now comes the difficult part: creating a filter of articles where this latter condition is true. I have tried many things that don't work, so this is what I have at the moment:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works - however, it is &lt;EM&gt;extremely slow.&amp;nbsp;&lt;/EM&gt;As you may have already realized, the &lt;STRONG&gt;FILTER(...) &lt;/STRONG&gt;with my boolean filter condition is the culprit. The measure takes about 15-20 seconds to calculate upon each new selection. The datamodel is neither complex nor large (I'm working with a tiny subset of the real data).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Note that the TREATAS comes from the fact that I have a&amp;nbsp; relationship (many:many, if that matters) between my Fact table and a another table ("ASP") where all prices are already calculated per article, company and year-month (it's not connected to the calendar, hence TREATAS). The thinking behing this was simply to avoid summarizing too much on the fly.&lt;/P&gt;&lt;H3&gt;Data model&lt;/H3&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions are: 1) &lt;U&gt;Has anyone ever done this specific kind of analysis&lt;/U&gt;; 2) &lt;U&gt;Is there anything you see directly here that should change for a better performance&lt;/U&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will also gladly accept any improvement suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 15:17:46 GMT</pubDate>
    <dc:creator>dpollozhani</dc:creator>
    <dc:date>2021-10-12T15:17:46Z</dc:date>
    <item>
      <title>Include only articles that have moved consecutively during selected months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2130170#M48877</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is my first post here, as I have only recently started working with PBI (I'm coming from a Qlik world, but that might change). With that in mind, I hope that I'm able to formulate my needs as clear as possible.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, I have a problem that I've been stuck for quite some while now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H2&gt;Intro&lt;/H2&gt;&lt;P&gt;I want to analyze the average sales price development on a monthly basis. The requirements are 1) Calculate the average price per company, article, and year-month; then sum these values up (it's specific to our situation); 2) &lt;STRONG&gt;Only analyze articles that have moved consecutively during the time period that is selected by the user,&lt;/STRONG&gt; i.e. if I select year 2021 and months jan-sept, I need to dynamically include only articles that have moved at least once per month during 2021 jan-sept.&lt;/P&gt;&lt;H2&gt;&lt;BR /&gt;Month measures&lt;/H2&gt;&lt;P&gt;For this I first deciced to calculate how many months are available in total (with a minor tweak to remove the current month under certain conditions), a number that should depend only on the time selection:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I calculate the months that are available, accepting all filters:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, I create a new measure that is a straight comparison between above two measure, i.e. a boolean that I mean to use as a filter later:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far so good, in as much as these measures verifiably work.&amp;nbsp;&lt;/P&gt;&lt;H2&gt;&lt;BR /&gt;Article filter&lt;/H2&gt;&lt;P&gt;Now comes the difficult part: creating a filter of articles where this latter condition is true. I have tried many things that don't work, so this is what I have at the moment:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works - however, it is &lt;EM&gt;extremely slow.&amp;nbsp;&lt;/EM&gt;As you may have already realized, the &lt;STRONG&gt;FILTER(...) &lt;/STRONG&gt;with my boolean filter condition is the culprit. The measure takes about 15-20 seconds to calculate upon each new selection. The datamodel is neither complex nor large (I'm working with a tiny subset of the real data).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Note that the TREATAS comes from the fact that I have a&amp;nbsp; relationship (many:many, if that matters) between my Fact table and a another table ("ASP") where all prices are already calculated per article, company and year-month (it's not connected to the calendar, hence TREATAS). The thinking behing this was simply to avoid summarizing too much on the fly.&lt;/P&gt;&lt;H3&gt;Data model&lt;/H3&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions are: 1) &lt;U&gt;Has anyone ever done this specific kind of analysis&lt;/U&gt;; 2) &lt;U&gt;Is there anything you see directly here that should change for a better performance&lt;/U&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will also gladly accept any improvement suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 15:17:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2130170#M48877</guid>
      <dc:creator>dpollozhani</dc:creator>
      <dc:date>2021-10-12T15:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Include only articles that have moved consecutively during selected months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2136530#M49065</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="303521" data-lia-user-login="dpollozhani" class="lia-mention lia-mention-user"&gt;dpollozhani&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try to use the measure below as a filter:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count =
COUNTROWS (
    EXCEPT ( VALUES ( 'Calendar'[Year Month] ), VALUES ( 'Sales'[Year Month] ) )
) = 0
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 05:58:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2136530#M49065</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2021-10-15T05:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Include only articles that have moved consecutively during selected months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2137194#M49076</link>
      <description>&lt;P&gt;This does work much, much better, thank you. Do you have an idea of what the reason for the improvement is?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 10:54:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Include-only-articles-that-have-moved-consecutively-during/m-p/2137194#M49076</guid>
      <dc:creator>dpollozhani</dc:creator>
      <dc:date>2021-10-15T10:54:40Z</dc:date>
    </item>
  </channel>
</rss>

