<?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: Aggregate Measure correctly by condition on DATEDIFF in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141529#M49232</link>
    <description>&lt;P&gt;Hmm. I think ALLSELECTED ( DATUM ) is destroying the PROCESS filter context. Try ALLSELECTED ( DATUM[Date] ) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure that this will work though. There's a decent chance you'll have &lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_blank"&gt;auto-exists&lt;/A&gt; trouble without a date dimension table.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Oct 2021 21:33:44 GMT</pubDate>
    <dc:creator>AlexisOlson</dc:creator>
    <dc:date>2021-10-18T21:33:44Z</dc:date>
    <item>
      <title>Aggregate Measure correctly by condition on DATEDIFF</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141188#M49215</link>
      <description>&lt;P&gt;I have the following Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It represents processes with a certain category.&lt;/P&gt;&lt;P&gt;And there is also a Date Table over column TIMESTAMP.&lt;/P&gt;&lt;P&gt;I would like to show a Measure based on another Measure that calculates the Date-Difference until the selected Date.&lt;/P&gt;&lt;P&gt;So first this is how I calculate the Date-Difference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AGE = &lt;BR /&gt;VAR SELECTED_DATE = CALCULATE(MAX(DATUM[Date]), ALLSELECTED(DATUM))&lt;BR /&gt;VAR STARTDATE_PROCESS = Calculate(MAX(Workflow[MIN_TIMESTAMP]),DATUM[Date]&amp;lt;=MAX(DATUM[Date]), ALL(DATUM[Date]))&lt;BR /&gt;RETURN&lt;BR /&gt;DATEDIFF(STARTDATE_PROCESS,SELECTED_DATE,DAY)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to use a Measure which depends on the result of AGE, like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;NEW = IF([AGE]&amp;lt;=3,CALCULATE(COUNT(Workflow[PROCESS]),ALL(DATUM)))&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;OLD = IF([AGE]&amp;gt;3,CALCULATE(COUNT(Workflow[PROCESS]),ALL(DATUM)))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works so far, but the aggregation is not working correctly as you can see here, there should be a 3 on NEW and OLD aggregated:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to fix that?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 16:04:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141188#M49215</guid>
      <dc:creator>Lourini90</dc:creator>
      <dc:date>2021-10-18T16:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Measure correctly by condition on DATEDIFF</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141202#M49216</link>
      <description>&lt;P&gt;You need to sum over each process individually or else the maximums in AGE are taken over all of the processes simultaneously rather than one at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SumNew = SUMX ( VALUES ( Workflow[PROCESS] ), [New] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 16:24:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141202#M49216</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-10-18T16:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Measure correctly by condition on DATEDIFF</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141286#M49222</link>
      <description>&lt;P&gt;Thanks for replying!&lt;BR /&gt;For some reason nothing is shown here:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;any idea? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:56:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141286#M49222</guid>
      <dc:creator>Lourini90</dc:creator>
      <dc:date>2021-10-18T17:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Measure correctly by condition on DATEDIFF</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141529#M49232</link>
      <description>&lt;P&gt;Hmm. I think ALLSELECTED ( DATUM ) is destroying the PROCESS filter context. Try ALLSELECTED ( DATUM[Date] ) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure that this will work though. There's a decent chance you'll have &lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_blank"&gt;auto-exists&lt;/A&gt; trouble without a date dimension table.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 21:33:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2141529#M49232</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-10-18T21:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Measure correctly by condition on DATEDIFF</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2147256#M49437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="328408" data-lia-user-login="Lourini90" class="lia-mention lia-mention-user"&gt;Lourini90&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can try to modify the measures like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NEW = 
IF (
    HASONEVALUE ( 'Workflow'[PROCESS] ),
    IF ( [AGE] &amp;lt;= 3, CALCULATE ( COUNT ( 'Workflow'[PROCESS] ), ALL ( DATUM ) ) ),
    CALCULATE ( COUNT ( Workflow[PROCESS] ), FILTER ( 'Workflow', [AGE] &amp;lt;= 3 ) )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;OLD = 
IF (
    HASONEVALUE ( 'Workflow'[PROCESS] ),
    IF ( [AGE] &amp;gt; 3, CALCULATE ( COUNT ( 'Workflow'[PROCESS] ), ALL ( DATUM ) ) ),
    CALCULATE ( COUNT ( Workflow[PROCESS] ), FILTER ( 'Workflow', [AGE] &amp;gt; 3 ) )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 06:12:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-Measure-correctly-by-condition-on-DATEDIFF/m-p/2147256#M49437</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-10-21T06:12:19Z</dc:date>
    </item>
  </channel>
</rss>

