<?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 Dax to calculate last 12 month and Current month flag for the local time zone in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-to-calculate-last-12-month-and-Current-month-flag-for-the/m-p/814676#M5355</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to create the calculated columns for the Last 12 months and Current Month flag, Date ranges should be calculated based on the user timezone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eg. If the user is in Australia on the end of month he might be in next month 'November' for the UTC date whereas UK user current month could be 'October' only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below tables with the column names:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;Sales&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calenderdate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date&amp;nbsp; Amount&amp;nbsp; &amp;nbsp;Country&amp;nbsp; &amp;nbsp;Timezone&amp;nbsp; &amp;nbsp;CurrentLocalTime&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried mulitple ways but not succeded yet, any help on this much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pankaj&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2019 11:34:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-10-10T11:34:56Z</dc:date>
    <item>
      <title>Dax to calculate last 12 month and Current month flag for the local time zone</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-to-calculate-last-12-month-and-Current-month-flag-for-the/m-p/814676#M5355</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to create the calculated columns for the Last 12 months and Current Month flag, Date ranges should be calculated based on the user timezone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eg. If the user is in Australia on the end of month he might be in next month 'November' for the UTC date whereas UK user current month could be 'October' only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below tables with the column names:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;Sales&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calenderdate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date&amp;nbsp; Amount&amp;nbsp; &amp;nbsp;Country&amp;nbsp; &amp;nbsp;Timezone&amp;nbsp; &amp;nbsp;CurrentLocalTime&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried mulitple ways but not succeded yet, any help on this much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pankaj&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 11:34:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-to-calculate-last-12-month-and-Current-month-flag-for-the/m-p/814676#M5355</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-10T11:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dax to calculate last 12 month and Current month flag for the local time zone</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-to-calculate-last-12-month-and-Current-month-flag-for-the/m-p/3980950#M154368</link>
      <description>&lt;P&gt;To handle time zone differences and create calculated columns for the last 12 months and current month flags based on user time zones, you need to adjust your calculations based on the local time. Here's how you can achieve this:&lt;/P&gt;
&lt;P&gt;Step 1: Adjust for Local Time&lt;BR /&gt;First, create a calculated column that adjusts the Calenderdate to the local time based on the Timezone information.&lt;/P&gt;
&lt;P&gt;Local DateTime Calculation&lt;BR /&gt;Assuming you have the Timezone as the UTC offset in hours, you can create a column to adjust for local time:&lt;/P&gt;
&lt;P&gt;LocalDateTime = &lt;BR /&gt;DATEADD(&lt;BR /&gt;'Sales'[Calenderdate],&lt;BR /&gt;'Sales'[Timezone],&lt;BR /&gt;HOUR&lt;BR /&gt;)&lt;BR /&gt;Step 2: Current Month Flag&lt;BR /&gt;Create a calculated column to flag the current month based on the local date:&lt;/P&gt;
&lt;P&gt;CurrentMonthFlag = &lt;BR /&gt;VAR LocalDate = 'Sales'[LocalDateTime]&lt;BR /&gt;VAR CurrentLocalDate = TODAY() + TIMEVALUE('Sales'[Timezone] / 24)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;YEAR(LocalDate) = YEAR(CurrentLocalDate) &amp;amp;&amp;amp; MONTH(LocalDate) = MONTH(CurrentLocalDate),&lt;BR /&gt;"Current Month",&lt;BR /&gt;"Not Current Month"&lt;BR /&gt;)&lt;BR /&gt;Step 3: Last 12 Months Flag&lt;BR /&gt;Create a calculated column to flag dates within the last 12 months based on the local date:&lt;/P&gt;
&lt;P&gt;Last12MonthsFlag = &lt;BR /&gt;VAR LocalDate = 'Sales'[LocalDateTime]&lt;BR /&gt;VAR CurrentLocalDate = TODAY() + TIMEVALUE('Sales'[Timezone] / 24)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;LocalDate &amp;gt;= EDATE(CurrentLocalDate, -12) &amp;amp;&amp;amp; LocalDate &amp;lt; CurrentLocalDate,&lt;BR /&gt;"Last 12 Months",&lt;BR /&gt;"Not Last 12 Months"&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 01:57:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-to-calculate-last-12-month-and-Current-month-flag-for-the/m-p/3980950#M154368</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2024-06-08T01:57:15Z</dc:date>
    </item>
  </channel>
</rss>

