<?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: replicate spreadsheet calculation in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2494288#M35902</link>
    <description>&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddFJDoMwDAXQu7COhOfhLIht73+EEtNGJdAFKHJ4+Y7ZtgWXVs8LoK9oJV4JqJd6gc4yYEtN+l3ubVvogg9I3VaV9HjriaXVeQjU7NgO9dI8ax7aor6fOLfemScWl5nHl5NitX7TbvrJ1gkzDmz+0Dk3IfbwKG0XLevAjB3zHSe6FfWJ6qBSPd2DHVIgtHRMmgY3tLr5+F02RiYcXDr/ajd7HjgTKJzZCH95VPhDtmAq57Lvbw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code_operation = _t, branch = _t, code = _t, date = _t, #"amount day" = _t, Amount = _t, price = _t, #"replicate this formula" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"amount day", Int64.Type}, {"Amount", Int64.Type}, {"code_operation", Int64.Type}, {"date", type date}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"price", type number}}, "de-DE"),
    #"Sorted Rows" = Table.Sort(#"Changed Type with Locale",{{"code_operation", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if [Index]=0 then [price] else List.Accumulate({1..[Index]},#"Added Index"{0}[price],(state,current)=&amp;gt;(#"Added Index"{current}[amount day]*state+#"Added Index"{current}[Amount]*#"Added Index"{current}[price])/(#"Added Index"{current}[amount day]+#"Added Index"{current}[Amount])))
in
    #"Added Custom"&lt;/LI-CODE&gt;
&lt;P&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 19:50:23 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-05-04T19:50:23Z</dc:date>
    <item>
      <title>replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488566#M35851</link>
      <description>&lt;P&gt;&lt;FONT&gt;I'm trying to publish this formula of the spreadsheet in the power bi, but without success.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexsandro_0-1651406630189.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/707620i59D3C03846E22A9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alexsandro_0-1651406630189.png" alt="alexsandro_0-1651406630189.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;link of spreadsheet below:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="LINK DA PLANILHA" href="https://docs.google.com/spreadsheets/d/11BhRKjWPtPdeFuFvZSlBm0mesjtpGsWM/edit?usp=sharing&amp;amp;ouid=102623328097540554419&amp;amp;rtpof=true&amp;amp;sd=true" target="_self"&gt;&lt;FONT&gt;https://docs.google.com/spreadsheets/d/11BhRKjWPtPdeFuFvZSlBm0mesjtpGsWM/edit?usp=sharing&amp;amp;ouid=102623328097540554419&amp;amp;rtpof=true&amp;amp;sd=true&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 11:46:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488566#M35851</guid>
      <dc:creator>alexsandro</dc:creator>
      <dc:date>2022-05-02T11:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488621#M35853</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/333672"&gt;@alexsandro&lt;/a&gt;&amp;nbsp;You need to be able to return the previous row like in MTBF.&amp;nbsp;See my article on Mean Time Between Failure (MTBF) which uses EARLIER: &lt;A href="http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586" target="_blank"&gt;http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586&lt;/A&gt;.&lt;BR /&gt;The basic pattern is:&lt;BR /&gt;Column =&amp;nbsp;&lt;BR /&gt;&amp;nbsp; VAR __Current = [Value]&lt;BR /&gt;&amp;nbsp; VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] &amp;lt; EARLIER('Table'[Date])),[Date])&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])&lt;BR /&gt;RETURN&lt;BR /&gt;&amp;nbsp; __Current - __Previous&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 12:19:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488621#M35853</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-05-02T12:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488635#M35854</link>
      <description>&lt;P&gt;thanks Greg, I'll see.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 12:25:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2488635#M35854</guid>
      <dc:creator>alexsandro</dc:creator>
      <dc:date>2022-05-02T12:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2492144#M35890</link>
      <description>&lt;P&gt;unfortunately it didn't work as I need to iterate over the same previous calculation and not over the previous price&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 02:18:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2492144#M35890</guid>
      <dc:creator>alexsandro</dc:creator>
      <dc:date>2022-05-04T02:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2494288#M35902</link>
      <description>&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddFJDoMwDAXQu7COhOfhLIht73+EEtNGJdAFKHJ4+Y7ZtgWXVs8LoK9oJV4JqJd6gc4yYEtN+l3ubVvogg9I3VaV9HjriaXVeQjU7NgO9dI8ax7aor6fOLfemScWl5nHl5NitX7TbvrJ1gkzDmz+0Dk3IfbwKG0XLevAjB3zHSe6FfWJ6qBSPd2DHVIgtHRMmgY3tLr5+F02RiYcXDr/ajd7HjgTKJzZCH95VPhDtmAq57Lvbw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code_operation = _t, branch = _t, code = _t, date = _t, #"amount day" = _t, Amount = _t, price = _t, #"replicate this formula" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"amount day", Int64.Type}, {"Amount", Int64.Type}, {"code_operation", Int64.Type}, {"date", type date}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"price", type number}}, "de-DE"),
    #"Sorted Rows" = Table.Sort(#"Changed Type with Locale",{{"code_operation", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if [Index]=0 then [price] else List.Accumulate({1..[Index]},#"Added Index"{0}[price],(state,current)=&amp;gt;(#"Added Index"{current}[amount day]*state+#"Added Index"{current}[Amount]*#"Added Index"{current}[price])/(#"Added Index"{current}[amount day]+#"Added Index"{current}[Amount])))
in
    #"Added Custom"&lt;/LI-CODE&gt;
&lt;P&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 19:50:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2494288#M35902</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-05-04T19:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: replicate spreadsheet calculation</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2496099#M35924</link>
      <description>&lt;P&gt;IT WAS PERFECT, THANK YOU SO MUCH...&lt;BR /&gt;now I'm going to try to replicate this for several codes&lt;BR /&gt;you are very good at it, super professional&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 13:07:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/replicate-spreadsheet-calculation/m-p/2496099#M35924</guid>
      <dc:creator>alexsandro</dc:creator>
      <dc:date>2022-05-05T13:07:40Z</dc:date>
    </item>
  </channel>
</rss>

