<?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: DAX measure to calculate the percentage change in the stock price in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599468#M139089</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="586303" data-lia-user-login="Snook" class="lia-mention lia-mention-user"&gt;Snook&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the percentage change in the stock price for each ticker on a weekly, monthly, and annual basis, you can create three separate DAX measures in Power BI. The general approach for each measure is to calculate the opening price at the start of the period and the closing price at the end of the period, and then compute the percentage change between these two values.&lt;/P&gt;&lt;P&gt;Here's how you can create these measures:&lt;/P&gt;&lt;H3&gt;1. Weekly Percentage Change&lt;/H3&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the week to the closing price on the last trading day of the week.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Weekly Percentage Change = 
VAR WeekStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFWEEK('Table'[Date]))
VAR WeekEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFWEEK('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = WeekStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = WeekEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())2. Monthly Percentage Change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the month to the closing price on the last trading day of the month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Monthly Percentage Change = VAR MonthStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFMONTH('Table'[Date]))
VAR MonthEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFMONTH('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = MonthStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = MonthEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())3. Annual Percentage Change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the year to the closing price on the last trading day of the year.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Annual Percentage Change = 
VAR YearStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFYEAR('Table'[Date]))
VAR YearEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFYEAR('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = YearStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = YearEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In these measures, replace 'Table' with the actual name of your table. Each measure calculates the start and end of the respective period (week, month, year), finds the opening and closing prices, and then computes the percentage change. The ALLEXCEPT function is used to keep the filter context for the ticker while removing other filters that could affect the calculation of start and end dates.&lt;/P&gt;&lt;P&gt;Ensure that your 'Date' column is properly formatted as a date in Power BI for these calculations to work correctly. Also, note that these calculations assume that your data includes every trading day; if there are missing dates, you might need to adjust the logic to accommodate that.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If this post &lt;STRONG&gt;helps, please consider &lt;STRONG&gt;accepting&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank" rel="noopener noreferrer"&gt;LinkedIn | &lt;/A&gt;&lt;A href="https://twitter.com/VahidDMcom" target="_blank" rel="noopener noreferrer"&gt;Twitter | &lt;/A&gt;&lt;A href="https://www.vahiddm.com/" target="_blank" rel="noopener noreferrer"&gt;Blog&amp;nbsp;| &lt;/A&gt;&lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;YouTube&lt;/A&gt;&lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 23 Dec 2023 23:44:44 GMT</pubDate>
    <dc:creator>VahidDM</dc:creator>
    <dc:date>2023-12-23T23:44:44Z</dc:date>
    <item>
      <title>DAX measure to calculate the percentage change in the stock price</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599368#M139084</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to calculate the percentage difference for the closing price of a stock compared to the opening on a weekly, monthly and annual basis for each ticker (I presumably need three measures).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following is an example of the data I'm working with:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ticker Date Open Close&lt;BR /&gt;MMM 01/11/2023 $91.16 $90.56&lt;BR /&gt;MMM 02/11/2023 $91.60 $92.31&lt;BR /&gt;MMM 03/11/2023 $93.52 $93.86&lt;BR /&gt;MMM 06/11/2023 $93.83 $93.52&lt;BR /&gt;MMM 07/11/2023 $92.92 $93.15&lt;BR /&gt;MMM 08/11/2023 $93.40 $92.32&lt;BR /&gt;MMM 09/11/2023 $92.58 $91.70&lt;BR /&gt;MMM 10/11/2023 $92.00 $92.81&lt;BR /&gt;MMM 13/11/2023 $92.70 $92.69&lt;BR /&gt;MMM 14/11/2023 $94.00 $94.97&lt;BR /&gt;MMM 15/11/2023 $95.44 $96.82&lt;BR /&gt;MMM 16/11/2023 $95.89 $95.71&lt;BR /&gt;MMM 17/11/2023 $96.26 $95.34&lt;BR /&gt;MMM 20/11/2023 $95.02 $94.98&lt;BR /&gt;MMM 21/11/2023 $94.62 $93.99&lt;BR /&gt;MMM 22/11/2023 $94.97 $95.37&lt;BR /&gt;MMM 24/11/2023 $95.30 $95.95&lt;BR /&gt;MMM 27/11/2023 $96.00 $97.07&lt;BR /&gt;MMM 28/11/2023 $96.92 $98.51&lt;BR /&gt;MMM 29/11/2023 $99.25 $98.47&lt;BR /&gt;MMM 30/11/2023 $98.64 $99.07&lt;BR /&gt;AOS 01/11/2023 $70.08 $70.81&lt;BR /&gt;AOS 02/11/2023 $71.94 $71.35&lt;BR /&gt;AOS 03/11/2023 $72.25 $71.56&lt;BR /&gt;AOS 06/11/2023 $71.51 $71.09&lt;BR /&gt;AOS 07/11/2023 $70.73 $70.65&lt;BR /&gt;AOS 08/11/2023 $70.91 $71.14&lt;BR /&gt;AOS 09/11/2023 $71.42 $71.37&lt;BR /&gt;AOS 10/11/2023 $71.90 $72.82&lt;BR /&gt;AOS 13/11/2023 $72.41 $73.38&lt;BR /&gt;AOS 14/11/2023 $74.59 $76.02&lt;BR /&gt;AOS 15/11/2023 $76.00 $75.00&lt;BR /&gt;AOS 16/11/2023 $75.09 $75.64&lt;BR /&gt;AOS 17/11/2023 $76.13 $76.38&lt;BR /&gt;AOS 20/11/2023 $76.03 $76.11&lt;BR /&gt;AOS 21/11/2023 $75.91 $75.87&lt;BR /&gt;AOS 22/11/2023 $76.16 $75.88&lt;BR /&gt;AOS 24/11/2023 $75.78 $76.01&lt;BR /&gt;AOS 27/11/2023 $75.53 $75.96&lt;BR /&gt;AOS 28/11/2023 $75.67 $75.12&lt;BR /&gt;AOS 29/11/2023 $75.74 $75.10&lt;BR /&gt;AOS 30/11/2023 $75.10 $75.36&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;NB - I've also posted this query on the Excel forum I'm a member of (&lt;A href="https://www.excelforum.com/excel-formulas-and-functions/1416860-dax-measure-to-calculate-the-percentage-change-in-stock-price.html" target="_self"&gt;link&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Snook&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 00:12:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599368#M139084</guid>
      <dc:creator>Snook</dc:creator>
      <dc:date>2023-12-23T00:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to calculate the percentage change in the stock price</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599468#M139089</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="586303" data-lia-user-login="Snook" class="lia-mention lia-mention-user"&gt;Snook&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the percentage change in the stock price for each ticker on a weekly, monthly, and annual basis, you can create three separate DAX measures in Power BI. The general approach for each measure is to calculate the opening price at the start of the period and the closing price at the end of the period, and then compute the percentage change between these two values.&lt;/P&gt;&lt;P&gt;Here's how you can create these measures:&lt;/P&gt;&lt;H3&gt;1. Weekly Percentage Change&lt;/H3&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the week to the closing price on the last trading day of the week.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Weekly Percentage Change = 
VAR WeekStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFWEEK('Table'[Date]))
VAR WeekEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFWEEK('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = WeekStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = WeekEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())2. Monthly Percentage Change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the month to the closing price on the last trading day of the month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Monthly Percentage Change = VAR MonthStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFMONTH('Table'[Date]))
VAR MonthEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFMONTH('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = MonthStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = MonthEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())3. Annual Percentage Change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure calculates the percentage change from the opening price on the first trading day of the year to the closing price on the last trading day of the year.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Annual Percentage Change = 
VAR YearStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFYEAR('Table'[Date]))
VAR YearEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFYEAR('Table'[Date]))
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = YearStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = YearEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In these measures, replace 'Table' with the actual name of your table. Each measure calculates the start and end of the respective period (week, month, year), finds the opening and closing prices, and then computes the percentage change. The ALLEXCEPT function is used to keep the filter context for the ticker while removing other filters that could affect the calculation of start and end dates.&lt;/P&gt;&lt;P&gt;Ensure that your 'Date' column is properly formatted as a date in Power BI for these calculations to work correctly. Also, note that these calculations assume that your data includes every trading day; if there are missing dates, you might need to adjust the logic to accommodate that.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If this post &lt;STRONG&gt;helps, please consider &lt;STRONG&gt;accepting&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank" rel="noopener noreferrer"&gt;LinkedIn | &lt;/A&gt;&lt;A href="https://twitter.com/VahidDMcom" target="_blank" rel="noopener noreferrer"&gt;Twitter | &lt;/A&gt;&lt;A href="https://www.vahiddm.com/" target="_blank" rel="noopener noreferrer"&gt;Blog&amp;nbsp;| &lt;/A&gt;&lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;YouTube&lt;/A&gt;&lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 23:44:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599468#M139089</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2023-12-23T23:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to calculate the percentage change in the stock price</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599878#M139095</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="315278" data-lia-user-login="VahidDM" class="lia-mention lia-mention-user"&gt;VahidDM&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to implement your formula but I receive the following error message when I input it.&lt;/P&gt;&lt;P&gt;'Failed to resolve name 'STARTOFWEEK'. It is not a valid table, variable, or function name.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts on where I'm going wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Snook&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 16:21:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3599878#M139095</guid>
      <dc:creator>Snook</dc:creator>
      <dc:date>2023-12-23T16:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to calculate the percentage change in the stock price</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3600001#M139103</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="586303" data-lia-user-login="Snook" class="lia-mention lia-mention-user"&gt;Snook&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was my bad, thanks for letting me know.&lt;/P&gt;&lt;P&gt;try to update those dax with these:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Start of Week&lt;/STRONG&gt;: You can calculate the start of the week (assuming Sunday as the first day) with:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;StartOfWeek = YourDateColumn - WEEKDAY(YourDateColumn, 1) + 1&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;This formula adjusts the date to the previous Sunday. If your week starts on a different day, you'll need to modify the formula accordingly.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;End of Week&lt;/STRONG&gt;: To find the end of the week (assuming Saturday as the last day), you can use:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;EndOfWeek = YourDateColumn + (7 - WEEKDAY(YourDateColumn, 1))&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;This formula adjusts the date to the next Saturday.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 23:48:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3600001#M139103</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2023-12-23T23:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to calculate the percentage change in the stock price</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3600026#M139105</link>
      <description>&lt;P&gt;I'm still struggling I'm afraid&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="315278" data-lia-user-login="VahidDM" class="lia-mention lia-mention-user"&gt;VahidDM&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":pensive_face:"&gt;😔&lt;/span&gt; I've tried updating the code a variety of ways but I keep returning an error message. I'd be grateful if you (or someone else) could update the code so I can see where I'm going wrong (I'm a DAX beginner).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried adding the formulas above as two new variables but I receive the error message.&lt;/P&gt;&lt;P&gt;'A single value for column 'Date' in table 'Table' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW, this is where I'm at with my updated formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Weekly Percentage Change = 
VAR STARTOFWEEK = 'Table'[Date] - WEEKDAY('Table'[Date], 1) + 1
VAR ENDOFWEEK = 'Table'[Date] + (7 - WEEKDAY('Table'[Date], 1))
VAR WeekStart = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), STARTOFWEEK)
VAR WeekEnd = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Ticker]), ENDOFWEEK)
VAR OpeningPrice = CALCULATE(MIN('Table'[Open]), 'Table'[Date] = WeekStart)
VAR ClosingPrice = CALCULATE(MAX('Table'[Close]), 'Table'[Date] = WeekEnd)
RETURN IF(OpeningPrice &amp;gt; 0, (ClosingPrice - OpeningPrice) / OpeningPrice, BLANK())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Snook&lt;/P&gt;</description>
      <pubDate>Sun, 24 Dec 2023 01:04:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-calculate-the-percentage-change-in-the-stock/m-p/3600026#M139105</guid>
      <dc:creator>Snook</dc:creator>
      <dc:date>2023-12-24T01:04:57Z</dc:date>
    </item>
  </channel>
</rss>

