<?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 Replication of an Excel file calculation - circular dependency issue in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3325428#M124518</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to replicate a calculation (quite simple) in Excel in a PowerBi file. I've tried several times but have an issue of circular dependency. I have not been able to break it so far so i would appreciate any help/ideas on how to model the Excel in PowerBi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here below the Excel file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-YYGL9Dn0l5" target="_self"&gt;https://we.tl/t-YYGL9Dn0l5&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 14:03:03 GMT</pubDate>
    <dc:creator>Rolly_oo</dc:creator>
    <dc:date>2023-07-11T14:03:03Z</dc:date>
    <item>
      <title>Replication of an Excel file calculation - circular dependency issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3325428#M124518</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to replicate a calculation (quite simple) in Excel in a PowerBi file. I've tried several times but have an issue of circular dependency. I have not been able to break it so far so i would appreciate any help/ideas on how to model the Excel in PowerBi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here below the Excel file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-YYGL9Dn0l5" target="_self"&gt;https://we.tl/t-YYGL9Dn0l5&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:03:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3325428#M124518</guid>
      <dc:creator>Rolly_oo</dc:creator>
      <dc:date>2023-07-11T14:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of an Excel file calculation - circular dependency issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3333206#M124958</link>
      <description>&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc7BCQAhDAXRXv5ZMCbRxVqC/bexSFDj7vUdhjGDZKHMxIIEwkiGFoSdeqDHqXAwcVstPdQi1Ss2qXxiui9Wq/6+jvRbxgs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Inflow = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Inflow", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Capital Calc", each List.Accumulate({0..[Index]},[Roc=0,Cc=160],(state,current)=&amp;gt;[Roc = List.Min({state[Cc],#"Added Index"[Inflow]{current}}),Cc = state[Cc]-Roc]
 )),
    #"Expanded Capital Calc" = Table.ExpandRecordColumn(#"Added Custom", "Capital Calc", {"Cc", "Roc"}, {"Capital calc", "Roc"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Capital Calc",each [Capital calc],each if [Index]&amp;gt;0 then #"Expanded Capital Calc"[Capital calc]{[Index]-1} else [Capital calc],Replacer.ReplaceValue,{"Capital calc"}),
    #"Added Custom1" = Table.AddColumn(#"Replaced Value", "Realized gain", each if [Capital calc]=0 then [Inflow] else List.Max({0,[Inflow]-[Capital calc]}))
in
    #"Added Custom1"&lt;/LI-CODE&gt;
&lt;P&gt;This is not just a circular dependency but also a reverse circular.&amp;nbsp; Not something you want to do in Power BI&amp;nbsp; that often.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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>Sun, 16 Jul 2023 22:04:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3333206#M124958</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-07-16T22:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of an Excel file calculation - circular dependency issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3346714#M125662</link>
      <description>&lt;P&gt;Hello! Many thanks for the great answer/solution to my issue! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 14:05:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replication-of-an-Excel-file-calculation-circular-dependency/m-p/3346714#M125662</guid>
      <dc:creator>Rolly_oo</dc:creator>
      <dc:date>2023-07-24T14:05:32Z</dc:date>
    </item>
  </channel>
</rss>

