<?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: Moving range calcultion in PowerBI service is slow in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883842#M40550</link>
    <description>&lt;P&gt;Please find .pbix file here:&lt;/P&gt;&lt;P&gt;&lt;A title="Moving range Power BI desktop file" href="https://drive.google.com/file/d/1PDgqHughOinQOll2C7L_GCYdDxiVUWdq/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1PDgqHughOinQOll2C7L_GCYdDxiVUWdq/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that this is not actual file, trimmed version and so RecordID column is not as calculated column. This is the max I can share on community forum.&lt;/P&gt;</description>
    <pubDate>Sun, 06 Jun 2021 15:26:57 GMT</pubDate>
    <dc:creator>mahenkj2</dc:creator>
    <dc:date>2021-06-06T15:26:57Z</dc:date>
    <item>
      <title>Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883786#M40543</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have referred the below link to create moving range to create Individual-Moving range chart in Power BI:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/Moving-Range-DAX-subtract-previous-row-values-from-earlier/m-p/362905" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/Moving-Range-DAX-subtract-previous-row-values-from-earlier/m-p/362905&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a .pbix file first with sample data and it works perfectly fine in the desktop version, but when I publish, visual just cant show the trends and it times out eventually. I dont see the way I can share the .pbix file, so submit codes used by me below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below are the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Moving Range = 

VAR EarlierRecordID =
    CALCULATE (
        MAX ( Sheet1[RecordID] ),
        FILTER (
            ALLSELECTED ( Sheet1[RecordID]),
            Sheet1[RecordID] &amp;lt; SELECTEDVALUE ( Sheet1[RecordID] )
        )
    )

VAR EarlierMeasurementValue =
    CALCULATE ( SUM ( Sheet1[Measurement value] ), Sheet1[RecordID] = EarlierRecordID )
RETURN
    IF(ISBLANK(EarlierRecordID),BLANK(),   ABS ( EarlierMeasurementValue - SUM ( Sheet1[Measurement value] ) ))&lt;/LI-CODE&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;&lt;LI-CODE lang="markup"&gt;AverageMovingRange = AverageX(ALLSELECTED(Sheet1[RecordID]),[Moving Range])&lt;/LI-CODE&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;&lt;LI-CODE lang="markup"&gt;AverageClad = AVERAGEX(ALLSELECTED(Sheet1),Sheet1[Measurement value])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sheet1 is the main table and I use above measures in the visuals. RecordID field is a calculated column and fetches unique ID with RELATED function. This RecordID is being used as x axis label in the said visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect, either the DAX functions when being used in large table are causing the issue or the calculated column is the cause of problem. But sheet1 is imported table, so I also think that calculated column as such shoudl not be an issue in service, as it shoudl be stored value and while refreshing visual it should not hamper the performance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also submit sample data of sheet1&amp;nbsp; below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RecordID&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; Product ID&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; Measurement value | Process Date&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;5739494522&lt;/TD&gt;&lt;TD&gt;Product ID 1009&lt;/TD&gt;&lt;TD&gt;125.196&lt;/TD&gt;&lt;TD&gt;08-01-2020 11:08:13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739494241&lt;/TD&gt;&lt;TD&gt;Product ID 1008&lt;/TD&gt;&lt;TD&gt;124.888&lt;/TD&gt;&lt;TD&gt;08-01-2020 23:45:03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493962&lt;/TD&gt;&lt;TD&gt;Product ID 1007&lt;/TD&gt;&lt;TD&gt;124.888&lt;/TD&gt;&lt;TD&gt;09-01-2020 03:07:28&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493942&lt;/TD&gt;&lt;TD&gt;Product ID 1006&lt;/TD&gt;&lt;TD&gt;125.03&lt;/TD&gt;&lt;TD&gt;09-01-2020 08:15:31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493621&lt;/TD&gt;&lt;TD&gt;Product ID 1005&lt;/TD&gt;&lt;TD&gt;125.03&lt;/TD&gt;&lt;TD&gt;10-01-2020 04:37:35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493398&lt;/TD&gt;&lt;TD&gt;Product ID 1004&lt;/TD&gt;&lt;TD&gt;124.894&lt;/TD&gt;&lt;TD&gt;11-01-2020 02:05:52&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493208&lt;/TD&gt;&lt;TD&gt;Product ID 1003&lt;/TD&gt;&lt;TD&gt;124.894&lt;/TD&gt;&lt;TD&gt;11-01-2020 13:57:44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739493018&lt;/TD&gt;&lt;TD&gt;Product ID 1002&lt;/TD&gt;&lt;TD&gt;124.869&lt;/TD&gt;&lt;TD&gt;12-01-2020 06:08:57&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739492828&lt;/TD&gt;&lt;TD&gt;Product ID 1001&lt;/TD&gt;&lt;TD&gt;124.869&lt;/TD&gt;&lt;TD&gt;12-01-2020 20:04:47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5739492806&lt;/TD&gt;&lt;TD&gt;Product ID 1000&lt;/TD&gt;&lt;TD&gt;124.714&lt;/TD&gt;&lt;TD&gt;13-01-2020 02:23:32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5738743706&lt;/TD&gt;&lt;TD&gt;Product ID 100&lt;/TD&gt;&lt;TD&gt;124.919&lt;/TD&gt;&lt;TD&gt;06-04-2021 04:20:28&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5738582411&lt;/TD&gt;&lt;TD&gt;Product ID 10&lt;/TD&gt;&lt;TD&gt;125.032&lt;/TD&gt;&lt;TD&gt;21-05-2021 07:23:17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5738575049&lt;/TD&gt;&lt;TD&gt;Product ID 1&lt;/TD&gt;&lt;TD&gt;124.884&lt;/TD&gt;&lt;TD&gt;26-05-2021 18:56:11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jun 2021 12:52:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883786#M40543</guid>
      <dc:creator>mahenkj2</dc:creator>
      <dc:date>2021-06-06T12:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883817#M40548</link>
      <description>&lt;P&gt;&lt;STRONG&gt;"I dont see the way I can share the .pbix file,"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Just put the file on some shared drive - Google Drive, Dropbox, OneDrive... - and paste a link to the file in here. This is how you share files.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jun 2021 14:39:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883817#M40548</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-06-06T14:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883842#M40550</link>
      <description>&lt;P&gt;Please find .pbix file here:&lt;/P&gt;&lt;P&gt;&lt;A title="Moving range Power BI desktop file" href="https://drive.google.com/file/d/1PDgqHughOinQOll2C7L_GCYdDxiVUWdq/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1PDgqHughOinQOll2C7L_GCYdDxiVUWdq/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that this is not actual file, trimmed version and so RecordID column is not as calculated column. This is the max I can share on community forum.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jun 2021 15:26:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883842#M40550</guid>
      <dc:creator>mahenkj2</dc:creator>
      <dc:date>2021-06-06T15:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883843#M40551</link>
      <description>&lt;P&gt;You can try these. I checked them on a sample model built with the data you provided. 'T' is the table's name and I abbreviated some of the fields' names. The assumption is that RecordID is a unique column. You'll notice that the [Moving Range] measure does not use CALCULATE. This is in order to avoid context transition which is a very costly operation. If you want to speed up the other measures, you'll have to get rid of CALCULATE from wherever possible and duplicate the code that's in [Moving Range] in other measures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;DEFINE 

MEASURE T[Moving Range] = 
IF( ISINSCOPE( T[RecordID] ),

    var CurrentRecordID = SELECTEDVALUE( T[RecordID] )
    var CurrentMeasurement = SELECTEDVALUE( T[Measurement] )
    var EarlierMeasurement =
        MAXX(
            TOPN(1,
                FILTER(
                    ALLSELECTED( T ),
                    T[RecordID] &amp;lt; CurrentRecordID
                ),
                T[RecordID],
                DESC
            ),
            T[Measurement]
         )
     var Result =
        if( not ISBLANK( EarlierMeasurement ),
            abs( EarlierMeasurement - CurrentMeasurement )
        )
     return
        Result
)

MEASURE T[AverageMovingRange] = 
AVERAGEX(
    ALLSELECTED( T ),
    [Moving Range]
)

MEASURE T[AverageClad] = 
AVERAGEX(
    ALLSELECTED( T ),
    T[Measurement]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jun 2021 15:46:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883843#M40551</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-06-06T15:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883882#M40564</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;Thanks. If RecordID is not unique, what should I do in that case?&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jun 2021 17:30:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1883882#M40564</guid>
      <dc:creator>mahenkj2</dc:creator>
      <dc:date>2021-06-06T17:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1884899#M40588</link>
      <description>&lt;P&gt;Then you have a data quality problem and should clean the data.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 08:47:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1884899#M40588</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-06-07T08:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1886858#M40632</link>
      <description>&lt;P&gt;RecordID is unique in my case due to slicers being applied at the time of report viewing. I asked to understand what it can cause and then to make proper proofing for any such effects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your support. I publoshed the report and it works well.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 04:34:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1886858#M40632</guid>
      <dc:creator>mahenkj2</dc:creator>
      <dc:date>2021-06-08T04:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Moving range calcultion in PowerBI service is slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1888784#M40685</link>
      <description>&lt;P&gt;If &lt;STRONG&gt;RecordID&lt;/STRONG&gt; were non-unique, then the variable &lt;STRONG&gt;EarlierMeasurement&lt;/STRONG&gt; in &lt;STRONG&gt;[Moving Range]&lt;/STRONG&gt; would obtain the measurement of the highest value among all the measurements with the same &lt;STRONG&gt;RecordID&lt;/STRONG&gt;, which could or could not be what you want. However, &lt;STRONG&gt;RecordID&lt;/STRONG&gt; is a name that strongly suggests it is/should be unique.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 17:43:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-range-calcultion-in-PowerBI-service-is-slow/m-p/1888784#M40685</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-06-08T17:43:18Z</dc:date>
    </item>
  </channel>
</rss>

