<?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: MAXDate and Maxdate)lastyear with value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3905244#M152143</link>
    <description>&lt;P&gt;"Same day" is always 364 (52*7) regardless of leap year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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 or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &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>Thu, 09 May 2024 11:23:51 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-05-09T11:23:51Z</dc:date>
    <item>
      <title>MAXDate and Maxdate)lastyear with value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3902304#M152055</link>
      <description>&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I am trying to make a KPI card which shows how much we invoiced today and sameday last year. This it works. (see measure below).&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you can see below this is what the KPI looks like.&lt;/DIV&gt;&lt;DIV&gt;Right now same day last year shows blank as last year, now this day was weekend(see day 8 in example below) . However I want it to show 90 since its the max day last year that had a value (I dont want to show later than 2023-05-08)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;IRevenue MAX (This Year) =&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Revenue]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(c&lt;/SPAN&gt;&lt;SPAN&gt;alendar&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;calendar&lt;/SPAN&gt;&lt;SPAN&gt;[invoice_date]&lt;/SPAN&gt;&lt;SPAN&gt;=(&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(calendar&lt;/SPAN&gt;&lt;SPAN&gt;[invoice_date]&lt;/SPAN&gt;&lt;SPAN&gt;))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;IRevenue MAX (Last Year) = CALCULATE([Revenue],FILTER(calendar,calendar[invoice_date]=(max(calendar[invoice_date])&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;365&lt;/SPAN&gt;&lt;SPAN&gt;)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 May 2024 13:10:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3902304#M152055</guid>
      <dc:creator>RasmusN532</dc:creator>
      <dc:date>2024-05-08T13:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: MAXDate and Maxdate)lastyear with value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3903587#M152101</link>
      <description>&lt;P&gt;365 is wrong.&amp;nbsp; Same day last year is 364.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 23:23:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3903587#M152101</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-08T23:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: MAXDate and Maxdate)lastyear with value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3904615#M152130</link>
      <description>&lt;P&gt;Well I had 365 more of an example, and isnt it 366 since its leap year? Anyway thats not the issue here, I need it to look for the "highest date" last year not after this years maxdate, that has a value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 08:39:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3904615#M152130</guid>
      <dc:creator>RasmusN532</dc:creator>
      <dc:date>2024-05-09T08:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: MAXDate and Maxdate)lastyear with value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3905244#M152143</link>
      <description>&lt;P&gt;"Same day" is always 364 (52*7) regardless of leap year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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 or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &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>Thu, 09 May 2024 11:23:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3905244#M152143</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-09T11:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: MAXDate and Maxdate)lastyear with value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3931664#M152963</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="711381" data-lia-user-login="RasmusN532" class="lia-mention lia-mention-user"&gt;RasmusN532&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply from lbendlin&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try modifying your measure syntax as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IRevenue MAX (Last Year) =
VAR_a =
     MAX(calendar[invoice_date])
VAR SameDayLastYear =
     DATE ( YEAR ( _a ) - 1, MONTH ( _a ), DAY ( _a ) )
VAR_b =
     CALCULATE (
         MAX ( calendar[invoice_date] ),
         calendar[invoice_date] &amp;lt;= SameDayLastYear,
         NOT (ISBLANK ([Revenue] ) )
     )
RETURN
     CALCULATE ( [Revenue], FILTER ( calendar, calendar[invoice_date] = _b ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic of this measure is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start by determining the current date of the current year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Count the same day last year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finds the same or previous date in the last year that had revenue that was not null.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate the revenue for the corresponding date based on the found date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this modified syntax does not help you solve the problem, please provide me with the pbix file. Remember not to log in to the current account when uploading files to Power Bi Desktop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 07:20:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MAXDate-and-Maxdate-lastyear-with-value/m-p/3931664#M152963</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-20T07:20:50Z</dc:date>
    </item>
  </channel>
</rss>

