<?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 Get the last date of the last month of a dataset in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2862046#M92188</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to calculate the last date from my dataset for the last month, the formula works :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Measure = &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;CALCULATE&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;(LASTDATE(Inventory[History_Date]),MONTH(Inventory[History_Date])=MONTH(MAX(Inventory[History_Date]) - 1))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#008000"&gt;(on the 10/24/2022, returns the 09/28/2022 (last date of the last month in my dataset) )&lt;/FONT&gt;&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;However, when i use the measure in an other&amp;nbsp; CALCULATE formula, the result is wrong : the measure is interpreted as the last date of &lt;U&gt;&lt;FONT color="#FF0000"&gt;the current month instead if the last month&lt;/FONT&gt;&lt;/U&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Test formula :&lt;/EM&gt;&lt;/STRONG&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;Nb_devices_&lt;FONT color="#FF0000"&gt;M-1&lt;/FONT&gt; = CALCULATE(DISTINCTCOUNT(Inventory[ID]),FILTER(Inventory,Inventory[History_Date]=&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;[Measure]&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#008000"&gt;(on the 10/24/2022, returns the number of ID on the 10/24/2022, instead of the 09/28/2022 (last date of the last month in my dataset) )&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;Any idea ?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks !&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 25 Oct 2022 14:31:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-25T14:31:26Z</dc:date>
    <item>
      <title>Get the last date of the last month of a dataset</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2862046#M92188</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to calculate the last date from my dataset for the last month, the formula works :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Measure = &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;CALCULATE&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;(LASTDATE(Inventory[History_Date]),MONTH(Inventory[History_Date])=MONTH(MAX(Inventory[History_Date]) - 1))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#008000"&gt;(on the 10/24/2022, returns the 09/28/2022 (last date of the last month in my dataset) )&lt;/FONT&gt;&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;However, when i use the measure in an other&amp;nbsp; CALCULATE formula, the result is wrong : the measure is interpreted as the last date of &lt;U&gt;&lt;FONT color="#FF0000"&gt;the current month instead if the last month&lt;/FONT&gt;&lt;/U&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Test formula :&lt;/EM&gt;&lt;/STRONG&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;Nb_devices_&lt;FONT color="#FF0000"&gt;M-1&lt;/FONT&gt; = CALCULATE(DISTINCTCOUNT(Inventory[ID]),FILTER(Inventory,Inventory[History_Date]=&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;[Measure]&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;EM&gt;))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#008000"&gt;(on the 10/24/2022, returns the number of ID on the 10/24/2022, instead of the 09/28/2022 (last date of the last month in my dataset) )&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;Any idea ?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks !&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Oct 2022 14:31:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2862046#M92188</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-25T14:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get the last date of the last month of a dataset</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2862359#M92206</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , &lt;SPAN&gt;openingbalancemonth&lt;/SPAN&gt; of the month gives the value of last date of last month&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to use the date table joined with History_Date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;calculate(DISTINCTCOUNT(Inventory[ID]), &lt;SPAN&gt;openingbalancemonth&lt;/SPAN&gt; (Date[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;calculate(lastnonblankvalues(Inventory[History_Date], DISTINCTCOUNT(Inventory[ID])), &lt;SPAN&gt;previousmonth&lt;/SPAN&gt;(Date[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Power BI Allocating Targets: openingbalancemonth, openingbalancequarter, openingbalanceyear&lt;/SPAN&gt;: &lt;A href="https://youtu.be/6lzYOXI5wfo" target="_blank"&gt;https://youtu.be/6lzYOXI5wfo&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 16:52:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2862359#M92206</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-10-25T16:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get the last date of the last month of a dataset</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2863856#M92266</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please &lt;STRONG&gt;update&lt;/STRONG&gt; the formula of measure&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; [Nb_devices_M-1]&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt; as below and check if it can return the correct result:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Nb_devices_M-1 =
VAR _lastdate = [Measure]
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Inventory[ID] ),
        FILTER ( Inventory, Inventory[History_Date] = _lastdate )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your table '&lt;STRONG&gt;Inventory&lt;/STRONG&gt;' (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=05%7C01%7Cv-yiruan%40microsoft.com%7C52042a9abdcb4f87992108da9226a782%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637982991998684943%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=UtrFZ3zCvCcIHUi%2FVD3ptir0IqV85%2BozKiH9HbdDJHc%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 07:51:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2863856#M92266</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-26T07:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get the last date of the last month of a dataset</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2876224#M92950</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Whether your problem has been resolved? If yes, could you please mark the helpful post as &lt;STRONG&gt;&lt;SPAN&gt;Answered&lt;/SPAN&gt;&lt;/STRONG&gt;? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 06:03:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-last-date-of-the-last-month-of-a-dataset/m-p/2876224#M92950</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-01T06:03:54Z</dc:date>
    </item>
  </channel>
</rss>

