<?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 Visualize Data During Last 1 Year (Example: 01 June 2021 until 31 May 2022) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3527347#M135536</link>
    <description>&lt;P&gt;I have monthly data that will be updated every first day of the month.&lt;BR /&gt;I have a case, to visualize data during 1 last year, for example when slicer year = 2022 and month = 5, it will take data from 01 June 2021 until 31 May 2022. How to make dax to provide this case?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I tried to make &lt;STRONG&gt;dax on my Visual Studio&lt;/STRONG&gt; and it looks like this:&lt;BR /&gt;Last1Year :=&lt;BR /&gt;VAR Select_Month = MONTH(MAX(Test[postingdate]))&lt;BR /&gt;VAR Select_Year = YEAR(MAX(Test[postingdate]))&lt;BR /&gt;VAR StartDate = DATE(Select_Year - 1, Select_Month + 1, 1)&lt;BR /&gt;VAR EndDate = EOMONTH(StartDate, 11)&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;ABS(SUM(Test[value])),&lt;BR /&gt;FILTER(&lt;BR /&gt;Test,&lt;BR /&gt;Test[value] &amp;gt;= StartDate &amp;amp;&amp;amp;&lt;BR /&gt;Test[value] &amp;lt;= EndDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;but unfortunately, the output visual on my pbix when we put slicer year = 2022 and month = 5, it will just take value on May 2022.&lt;BR /&gt;Can you help me to correct my dax? Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;*Excel Link:&amp;nbsp;&lt;/STRONG&gt;&lt;U&gt;&lt;EM&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1nOkOOtVMdu0SXG21W5PR9dsyN42OQ_la/edit?usp=sharing&amp;amp;ouid=105487146609591265590&amp;amp;rtpof=true&amp;amp;sd=true" target="_blank"&gt;https://docs.google.com/spreadsheets/d/1nOkOOtVMdu0SXG21W5PR9dsyN42OQ_la/edit?usp=sharing&amp;amp;ouid=105487146609591265590&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/EM&gt;&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;This data h&lt;STRONG&gt;ave a relationship with calculated table DIM_DATE&lt;/STRONG&gt;, here's the dax for it:&lt;BR /&gt;DIM_DATE := ADDCOLUMNS(&lt;BR /&gt;CALENDAR(DATE(2018,1,1),EOMONTH(TODAY(),-1)),&lt;BR /&gt;"day", DAY([Date]),&lt;BR /&gt;"week", WEEKNUM([Date]),&lt;BR /&gt;"month", MONTH([Date]),&lt;BR /&gt;"monthname", FORMAT([Date],"mmm"),&lt;BR /&gt;"quarter", FORMAT([Date],"q"),&lt;BR /&gt;"quartername", "Q"&amp;amp;FORMAT([Date],"q"),&lt;BR /&gt;"year", YEAR([Date]),&lt;BR /&gt;"lastmonth", EOMONTH(TODAY(),-1)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2023 09:19:19 GMT</pubDate>
    <dc:creator>agustira97</dc:creator>
    <dc:date>2023-11-10T09:19:19Z</dc:date>
    <item>
      <title>Visualize Data During Last 1 Year (Example: 01 June 2021 until 31 May 2022)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3527347#M135536</link>
      <description>&lt;P&gt;I have monthly data that will be updated every first day of the month.&lt;BR /&gt;I have a case, to visualize data during 1 last year, for example when slicer year = 2022 and month = 5, it will take data from 01 June 2021 until 31 May 2022. How to make dax to provide this case?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I tried to make &lt;STRONG&gt;dax on my Visual Studio&lt;/STRONG&gt; and it looks like this:&lt;BR /&gt;Last1Year :=&lt;BR /&gt;VAR Select_Month = MONTH(MAX(Test[postingdate]))&lt;BR /&gt;VAR Select_Year = YEAR(MAX(Test[postingdate]))&lt;BR /&gt;VAR StartDate = DATE(Select_Year - 1, Select_Month + 1, 1)&lt;BR /&gt;VAR EndDate = EOMONTH(StartDate, 11)&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;ABS(SUM(Test[value])),&lt;BR /&gt;FILTER(&lt;BR /&gt;Test,&lt;BR /&gt;Test[value] &amp;gt;= StartDate &amp;amp;&amp;amp;&lt;BR /&gt;Test[value] &amp;lt;= EndDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;but unfortunately, the output visual on my pbix when we put slicer year = 2022 and month = 5, it will just take value on May 2022.&lt;BR /&gt;Can you help me to correct my dax? Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;*Excel Link:&amp;nbsp;&lt;/STRONG&gt;&lt;U&gt;&lt;EM&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1nOkOOtVMdu0SXG21W5PR9dsyN42OQ_la/edit?usp=sharing&amp;amp;ouid=105487146609591265590&amp;amp;rtpof=true&amp;amp;sd=true" target="_blank"&gt;https://docs.google.com/spreadsheets/d/1nOkOOtVMdu0SXG21W5PR9dsyN42OQ_la/edit?usp=sharing&amp;amp;ouid=105487146609591265590&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/EM&gt;&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;This data h&lt;STRONG&gt;ave a relationship with calculated table DIM_DATE&lt;/STRONG&gt;, here's the dax for it:&lt;BR /&gt;DIM_DATE := ADDCOLUMNS(&lt;BR /&gt;CALENDAR(DATE(2018,1,1),EOMONTH(TODAY(),-1)),&lt;BR /&gt;"day", DAY([Date]),&lt;BR /&gt;"week", WEEKNUM([Date]),&lt;BR /&gt;"month", MONTH([Date]),&lt;BR /&gt;"monthname", FORMAT([Date],"mmm"),&lt;BR /&gt;"quarter", FORMAT([Date],"q"),&lt;BR /&gt;"quartername", "Q"&amp;amp;FORMAT([Date],"q"),&lt;BR /&gt;"year", YEAR([Date]),&lt;BR /&gt;"lastmonth", EOMONTH(TODAY(),-1)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 09:19:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3527347#M135536</guid>
      <dc:creator>agustira97</dc:creator>
      <dc:date>2023-11-10T09:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Visualize Data During Last 1 Year (Example: 01 June 2021 until 31 May 2022)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3527573#M135545</link>
      <description>&lt;P&gt;Hope you are looking for below result. Your formula is correct. only you need to use selected value. Else you may use below formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;new value =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Test&lt;/SPAN&gt;&lt;SPAN&gt;[value]&lt;/SPAN&gt;&lt;SPAN&gt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lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DIM_DATE&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&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;</description>
      <pubDate>Fri, 10 Nov 2023 11:18:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3527573#M135545</guid>
      <dc:creator>Rupak_bi</dc:creator>
      <dc:date>2023-11-10T11:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Visualize Data During Last 1 Year (Example: 01 June 2021 until 31 May 2022)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3529439#M135612</link>
      <description>&lt;P&gt;Thank you for the solution, but what missing is, from your solution you are using 1 slicer, right now I using 2 different slicer Year and Month, so what if the case right that?&lt;BR /&gt;Hope you can also help me for this case...&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2023 12:55:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Visualize-Data-During-Last-1-Year-Example-01-June-2021-until-31/m-p/3529439#M135612</guid>
      <dc:creator>agustira97</dc:creator>
      <dc:date>2023-11-12T12:55:09Z</dc:date>
    </item>
  </channel>
</rss>

