<?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: Value 7 days earlier than selected in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4178999#M166040</link>
    <description>&lt;P&gt;&lt;SPAN class=""&gt;DATEADD&lt;/SPAN&gt;&lt;SPAN&gt;(SELECTEDVALUE('public Measurement'[DAY]),-&lt;/SPAN&gt;&lt;SPAN class=""&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;day&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2024 19:46:17 GMT</pubDate>
    <dc:creator>SachinNandanwar</dc:creator>
    <dc:date>2024-09-26T19:46:17Z</dc:date>
    <item>
      <title>Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4178931#M166038</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;Please help&lt;/P&gt;&lt;P&gt;I want to get information about the number of measurements (count of result) 7 days earlier than the selected day&lt;/P&gt;&lt;P&gt;The table with sample data looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;For example, I select the day: 2024-02-01 where there were 16 measurements and I need to create a measure showing how many measurements there were 7 days earlier&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The measure I wrote gives a "Blank" result every time. Where is the error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DAY - 7 =&lt;/P&gt;&lt;P&gt;var a = SELECTEDVALUE('public Measurement'[DAY])&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;CALCULATE(&lt;/P&gt;&lt;P&gt;COUNT('public Measurement'[result]); FILTER('public Measurement'; 'public &amp;nbsp;Measurement'[DAY] = a - 7&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; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 19:08:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4178931#M166038</guid>
      <dc:creator>Zbig62</dc:creator>
      <dc:date>2024-09-26T19:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4178999#M166040</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;DATEADD&lt;/SPAN&gt;&lt;SPAN&gt;(SELECTEDVALUE('public Measurement'[DAY]),-&lt;/SPAN&gt;&lt;SPAN class=""&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;day&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 19:46:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4178999#M166040</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-26T19:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4179030#M166042</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;Thank you for your quick response. I have a small problem with this function. If I use it in a variable definition&lt;BR /&gt;I get the message SYNTAX ERROR&lt;/P&gt;&lt;P&gt;day - 7 =&lt;/P&gt;&lt;P&gt;a =&amp;nbsp;&lt;SPAN class=""&gt;DATEADD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;FONT color="#993300"&gt;SELECTEDVALUE('public Measurement'[DAY])&lt;/FONT&gt;,-&lt;/SPAN&gt;&lt;SPAN class=""&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;day&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CALCULATE(&lt;/P&gt;&lt;P&gt;COUNT('public Measurement'[result]); FILTER('public Measurement'; 'public &amp;nbsp;Measurement'[DAY] = a&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; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 20:19:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4179030#M166042</guid>
      <dc:creator>Zbig62</dc:creator>
      <dc:date>2024-09-26T20:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4179152#M166050</link>
      <description>&lt;P&gt;You have to change the filter in your expression&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DAY - 7 =

CALCULATE (
    COUNT ( 'public Measurement'[result] ),
    FILTER (
        'public Measurement',
        'public  Measurement'[DAY]
            = DATEADD ( SELECTEDVALUE ( 'public Measurement'[DAY] ), -7, DAY )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Sep 2024 21:58:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4179152#M166050</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-26T21:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4180984#M166089</link>
      <description>&lt;P&gt;I have a problem with the type of parameters in and I don't know how to deal with it&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 05:05:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4180984#M166089</guid>
      <dc:creator>Zbig62</dc:creator>
      <dc:date>2024-09-27T05:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4181800#M166113</link>
      <description>&lt;P&gt;I tried another approach and I also get a message about parameter type mismatch&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 06:34:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4181800#M166113</guid>
      <dc:creator>Zbig62</dc:creator>
      <dc:date>2024-09-27T06:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4182276#M166132</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729059" data-lia-user-login="Zbig62" class="lia-mention lia-mention-user"&gt;Zbig62&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you should use the “DAY” field in the "public Measurement" table as a slicer, please create a calendar table to use as a slicer.&amp;nbsp;And don't create a relationship between the calendar table and the "public Measurement" table.&lt;/P&gt;
&lt;P&gt;1. Create a calendar table and use it as a slicer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Calendar = DISTINCT('public Measurement'[DAY])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2.&amp;nbsp;Replace the field “DAY” in your measure with the field “DAY” of calendar table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DAY - 7 = 
CALCULATE(
    COUNT('public Measurement'[result]),
    FILTER(
        'public Measurement',
        'public Measurement'[DAY] = SELECTEDVALUE('Calendar'[DAY]) - 7
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my simple test result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;By the way, when the day DAY-7 does not exist for the "DAY" in your data, the measure will return blank. For example, if you slicer selects 2024-02-01, DAY-7 is 2024-1-25, because the data for 2024-1-25 does not exist in your table, the measure returns blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;Best Regards,&lt;BR /&gt;Jarvis Tang&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 09:03:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4182276#M166132</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-27T09:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Value 7 days earlier than selected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4183950#M166162</link>
      <description>&lt;P&gt;Sorry I didnt realise that Dateadd function needs an exclusive date table.Your approach wouldnt work as you are trying to compare rows within the current row context and&amp;nbsp;subtracting from the same value using a filter.&lt;BR /&gt;&lt;BR /&gt;As suggested by&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;you need a date table. You can use the solution provided by&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 13:24:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Value-7-days-earlier-than-selected/m-p/4183950#M166162</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-27T13:24:59Z</dc:date>
    </item>
  </channel>
</rss>

