<?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: Calculating Price Indices over a Date Range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2673597#M79809</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="287667" data-lia-user-login="tcboutte" class="lia-mention lia-mention-user"&gt;tcboutte&lt;/a&gt; , Try a measure like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]),calculate([Measurement]* day(eomonth(max('Date'[date]),0))/90)),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH)) &lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 17:06:10 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-08-01T17:06:10Z</dc:date>
    <item>
      <title>Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2673501#M79806</link>
      <description>&lt;P&gt;I am struggling to figure out the best combination of measures to help a Power Bi visual match a source Excel file. The source file contains a price for each month of the year which are represented below and the Total column is what I am struggling with. "DaysSelected" is a measure that is there for my reference and reacts to my date slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The correct value for the Total column is 94.38 and is to be calculated as the sum of: Price per month *(days in that month/DaysSelected). For this example that would be 82.98*(31/90) + 91.63*(28/90) + 108.26*(31/90) = 94.38.&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;The measure in the matrix above is&amp;nbsp;NYMEX-CL = CALCULATE(AVERAGE('Price Indices'[Amount]),'Price Indices'[Category] = "NYMEX-CL") and below is the input data and DaysInMonth is a calculated column that I added. Any suggestions?&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>Mon, 01 Aug 2022 16:13:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2673501#M79806</guid>
      <dc:creator>tcboutte</dc:creator>
      <dc:date>2022-08-01T16:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2673597#M79809</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="287667" data-lia-user-login="tcboutte" class="lia-mention lia-mention-user"&gt;tcboutte&lt;/a&gt; , Try a measure like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]),calculate([Measurement]* day(eomonth(max('Date'[date]),0))/90)),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH)) &lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 17:06:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2673597#M79809</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-08-01T17:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2675662#M79935</link>
      <description>&lt;P&gt;Thanks. I am working with this now, but it looks like it be built to only handle the total days being 90. I'll need it to work with any number of months selected from my date slicer so that the denominator is dynamic. Do you think that is possible?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:12:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2675662#M79935</guid>
      <dc:creator>tcboutte</dc:creator>
      <dc:date>2022-08-02T13:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2680744#M80275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="287667" data-lia-user-login="tcboutte" class="lia-mention lia-mention-user"&gt;tcboutte&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to your description, Here's my solution. Create a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NYMEX-CL =
VAR _Av =
    CALCULATE (
        AVERAGE ( 'Price Indices'[Amount] ),
        'Price Indices'[Category] = "NYMEX-CL"
    )
RETURN
    IF (
        ISINSCOPE ( 'Price Indices'[Date] ),
        _Av,
        SUMX (
            FILTER ( 'Price Indices', 'Price Indices'[Category] = "NYMEX-CL" ),
            'Price Indices'[Amount]
                * DIVIDE ( 'Price Indices'[DaysInMonth], [DaysSelected] )
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;Get the correct result.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;I attach my sample below for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps,&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 07:14:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2680744#M80275</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-08-04T07:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2682028#M80356</link>
      <description>&lt;P&gt;Much appreciated! I just need to make one small change to how I was calculating my DaysSelected, but your measure did the trick after that. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 14:29:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2682028#M80356</guid>
      <dc:creator>tcboutte</dc:creator>
      <dc:date>2022-08-04T14:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2683270#M80437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="287667" data-lia-user-login="tcboutte" class="lia-mention lia-mention-user"&gt;tcboutte&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You're welcome! I thought DaysSelected was a column you've built, I see it in your screenshot。&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If not, just create a new table use&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/dax/generateseries-function" target="_blank"&gt;GENERATESERIES&lt;/A&gt;&amp;nbsp;function like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 05:35:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2683270#M80437</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-08-05T05:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2684248#M80498</link>
      <description>&lt;P&gt;All good! DaysSelected was actually a measure that calculated how many were currently selected on that page's slicer since we have about 2 years of data to work from.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 13:10:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2684248#M80498</guid>
      <dc:creator>tcboutte</dc:creator>
      <dc:date>2022-08-05T13:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Price Indices over a Date Range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2685921#M80668</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="287667" data-lia-user-login="tcboutte" class="lia-mention lia-mention-user"&gt;tcboutte&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If I understand correctly, you want to count the numbers be selected in the slicer, simply try:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DaysSelected = COUNTROWS(ALLSELECTED('Table'[Column]))&lt;/LI-CODE&gt;
&lt;P&gt;Get the correct value.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 01:40:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Price-Indices-over-a-Date-Range/m-p/2685921#M80668</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-08-08T01:40:33Z</dc:date>
    </item>
  </channel>
</rss>

