<?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: 12 Year Min/Max for running total in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4782403#M183125</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="141271" data-lia-user-login="kirbynguyen" class="lia-mention lia-mention-user"&gt;kirbynguyen&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Just wanted to check if you had a chance to go through the suggestions provided by the super users?&lt;BR /&gt;Were you able to resolve the issue?&lt;BR /&gt;If not, please consider sharing a sample data for better understanding.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Power-BI-Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_self"&gt;How to provide sample data&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank You!&lt;/P&gt;</description>
    <pubDate>Thu, 31 Jul 2025 06:30:49 GMT</pubDate>
    <dc:creator>v-sdhruv</dc:creator>
    <dc:date>2025-07-31T06:30:49Z</dc:date>
    <item>
      <title>12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4776586#M182937</link>
      <description>&lt;P&gt;Hello, I am using a running total measure to calculate the current month, the prev month, and the same month last year. The challenging part is creating the Range for the past 12 months. How can I calculate the 12 month min and the 12 month max?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Here are my measures for the current and previous month:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Current = 
VAR _day = SELECTEDVALUE(Dates2[Day Number])
VAR _sum = CALCULATE(SUM(Table[Volume]), Dates[Day Number] = _day)

RETURN
IF(ISBLANK(_sum), BLANK(),
CALCULATE(
	SUM(Table[Volume]),
	FILTER(
		ALLSELECTED(Dates[Day Number]),
		ISONORAFTER(Dates[Day Number], MAX(Dates[Day Number]), DESC) &amp;amp;&amp;amp;
        Dates[Day Number] &amp;lt;= _day
	)
))



LastMonth = 
VAR _day = SELECTEDVALUE(Dates2[Day Number])
VAR _month = SELECTEDVALUE(Dates[PrevMonthYearDate])
VAR _sum = CALCULATE(SUM(Table[Volume]), ALL(Dates), Dates[Day Number] = _day &amp;amp;&amp;amp; Dates[MonthYearDate] = _month)

RETURN
IF(ISBLANK(_sum), BLANK(),
CALCULATE(
	SUM(Table[Volume]),
	FILTER(
		ALL(Dates),
		ISONORAFTER(Dates[Day Number], MAX(Dates[Day Number]), DESC) &amp;amp;&amp;amp;
        Dates[Day Number] &amp;lt;= _day &amp;amp;&amp;amp; Dates[MonthYearDate] = _month
	)
))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset is simple. I use 3 tables, the Data table with Dates, Volumes, and Locations. The other 2 tables are Date tables. I use 2 date tables because the amount of days in the selected month may not be complete or will have less days than the previous month so the days after would not show.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(The yellow line after the end of the blue line won't show if I didn't use 2 date tables.)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2025 14:37:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4776586#M182937</guid>
      <dc:creator>kirbynguyen</dc:creator>
      <dc:date>2025-07-25T14:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: 12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4776635#M182943</link>
      <description>&lt;P&gt;You can use the same formula for all five measures, by using a CALENDAR filter that covers the desired range (single months, or 12 months etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obligatory note: Comparing days in months is suboptimal because these days will fall on different weekdays.&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;Do not include sensitive information. Do not include anything that is unrelated to the issue or question. &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Need help uploading data? &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" rel="noopener"&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;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" rel="noopener"&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>Fri, 25 Jul 2025 15:30:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4776635#M182943</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2025-07-25T15:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: 12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4777250#M182974</link>
      <description>&lt;P&gt;You can use a single Calendar, we shall fix the yellow line issue (which I assume is due to autoexist)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am not sure to get is what you mean by Range. It is completely clear what you mean by&amp;nbsp;&lt;SPAN&gt;current month, the prev month, and the same month last year, but the range part is a bit confusing to me&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you want limit a graph to the last 12 month or do you want in a single measure to calculate the last 12 month volume?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As Ibendin suggested, please provide data and expected output of this Range 12 month measure&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If this helped, please consider giving kudos and mark as a solution&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="273" data-lia-user-login="me" class="lia-mention lia-mention-user"&gt;me&lt;/a&gt; in replies or I'll lose your thread&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Want to check your DAX skills? &lt;A href="https://www.linkedin.com/company/kubisco/" target="_blank"&gt;Answer my biweekly DAX challenges on the kubisco Linkedin page&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Consider voting &lt;A href="https://community.fabric.microsoft.com/t5/Fabric-Ideas/Power-BI-Filter-Pane-as-an-icon-on-the-right-side-bar-in-on/idi-p/4728588" target="_blank"&gt;this Power BI idea&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Francesco Bergamaschi&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MBA, M.Eng, M.Econ, Professor of BI&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2025 18:42:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4777250#M182974</guid>
      <dc:creator>FBergamaschi</dc:creator>
      <dc:date>2025-07-26T18:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: 12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4777700#M182982</link>
      <description>&lt;P&gt;To calculate the Min and Max range for each day across the past 12 months, you can follow this approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create two additional DAX measures:&lt;/P&gt;
&lt;UL class="lia-list-style-type-square"&gt;
&lt;LI class="lia-indent-padding-left-30px"&gt;12M_Min: Running total minimum for each day number across the past 12 months&lt;/LI&gt;
&lt;LI class="lia-indent-padding-left-30px"&gt;12M_Max: Running total maximum for each day number across the past 12 months&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Notes:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;For each day (e.g., 1 to 31), calculate the cumulative sum up to that day for each of the past 12 months, then return the minimum and maximum from those 12 values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;12M_Min: DAX Measure&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;12M_Min =
VAR _day = SELECTEDVALUE(Dates2[Day Number])
VAR _last12Months =
    DATESINPERIOD(Dates[Date], MAX(Dates[Date]), -12, MONTH)
RETURN
MINX(
    VALUES(Dates[MonthYearDate]),
    CALCULATE(
        SUM(Table[Volume]),
        FILTER(
            ALL(Dates),
            Dates[Day Number] &amp;lt;= _day &amp;amp;&amp;amp;
            Dates[MonthYearDate] = EARLIER(Dates[MonthYearDate])
        ),
        _last12Months
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;12M_Max: DAX Measure&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;12M_Max =
VAR _day = SELECTEDVALUE(Dates2[Day Number])
VAR _last12Months =
    DATESINPERIOD(Dates[Date], MAX(Dates[Date]), -12, MONTH)
RETURN
MAXX(
    VALUES(Dates[MonthYearDate]),
    CALCULATE(
        SUM(Table[Volume]),
        FILTER(
            ALL(Dates),
            Dates[Day Number] &amp;lt;= _day &amp;amp;&amp;amp;
            Dates[MonthYearDate] = EARLIER(Dates[MonthYearDate])
        ),
        _last12Months
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;Notes:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;These measures assume your Dates table has a unique MonthYearDate (e.g., formatted as "Jul 2025").&lt;/LI&gt;
&lt;/UL&gt;
&lt;UL class="lia-list-style-type-disc"&gt;
&lt;LI&gt;We use VALUES(Dates[MonthYearDate]) to iterate over each of the last 12 months.&lt;/LI&gt;
&lt;LI&gt;The EARLIER function ensures that the filter context is respected during iteration.&lt;/LI&gt;
&lt;LI&gt;These measures give you the shaded band (min-max range) like in your first chart.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To reproduce the shaded band:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Plot 12M_Min and 12M_Max as area charts or use the Ribbon chart in Power BI.&lt;/LI&gt;
&lt;LI&gt;Overlay the Current, LastMonth, and SameMonthLastYear measures as lines for comparison.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you found this helpful, please consider marking it as the accepted solution and giving it a thumbs up.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 03:37:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4777700#M182982</guid>
      <dc:creator>Ilgar_Zarbali</dc:creator>
      <dc:date>2025-07-28T03:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: 12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4782403#M183125</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="141271" data-lia-user-login="kirbynguyen" class="lia-mention lia-mention-user"&gt;kirbynguyen&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Just wanted to check if you had a chance to go through the suggestions provided by the super users?&lt;BR /&gt;Were you able to resolve the issue?&lt;BR /&gt;If not, please consider sharing a sample data for better understanding.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Power-BI-Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_self"&gt;How to provide sample data&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank You!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 06:30:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4782403#M183125</guid>
      <dc:creator>v-sdhruv</dc:creator>
      <dc:date>2025-07-31T06:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: 12 Year Min/Max for running total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4783116#M183145</link>
      <description>&lt;P&gt;The earlier reply wasn't what I wanted, but it gave me an idea. Here is the answer:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;12M_Max = 
VAR _day = SELECTEDVALUE(Dates2[Day Number])
VAR _last12Months = DATESINPERIOD(Dates[Date], MAX(Dates[Date]), -12, MONTH)
VAR _month = SELECTEDVALUE(Dates[MonthYearDate])

RETURN
MAXX(
    ADDCOLUMNS(SUMMARIZE(FILTER(ALL(Dates), Dates[Date] IN _last12Months), Dates[MonthYearDate]),
    "RunningTotal",
    CALCULATE(
        SUM(KPLER[Volume (bbl)]),
        FILTER(
            ALL(Dates),
            Dates[Day Number] &amp;lt;= _day &amp;amp;&amp;amp;
            Dates[MonthYearDate] = EARLIER(Dates[MonthYearDate]) &amp;amp;&amp;amp; Dates[MonthYearDate] &amp;lt; _month
        )
    )
), [RunningTotal])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 13:43:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-Year-Min-Max-for-running-total/m-p/4783116#M183145</guid>
      <dc:creator>kirbynguyen</dc:creator>
      <dc:date>2025-07-31T13:43:20Z</dc:date>
    </item>
  </channel>
</rss>

