<?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: Circular dependency error in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4008814#M157399</link>
    <description>&lt;P&gt;Hi Lu,&lt;BR /&gt;Thanks for the details.&lt;/P&gt;&lt;P&gt;The requirement is to do all the calculations in PowerBI to reduce dependence on Excel. So, should I assume that this is something not possible using DAX?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 09:23:56 GMT</pubDate>
    <dc:creator>kmax</dc:creator>
    <dc:date>2024-06-25T09:23:56Z</dc:date>
    <item>
      <title>Circular dependency error</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4007400#M156957</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am facing a strange issue when creating a report.&lt;BR /&gt;Here are the details.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;There are two main slicers.&lt;BR /&gt;1- Year&lt;BR /&gt;2- LoB&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here are four main measures.&lt;BR /&gt;&lt;STRONG&gt;1- OB Initial&lt;/STRONG&gt; = this is the opening balance of a year. Value is coming from a small table.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2- OB Adjusted&lt;/STRONG&gt; = if column IsFirstMonth = 1, take value from &lt;STRONG&gt;[OB Initial]&lt;/STRONG&gt;, otherwise the Ending CARR value of previous month is the opening value of next month. e.g. if it is 2nd month, the &lt;STRONG&gt;obadjusted&lt;/STRONG&gt; value will be &lt;STRONG&gt;[Ending CARR]&lt;/STRONG&gt; of previous month. This is correctly getting the value of previous month as the opening value of next month.&lt;BR /&gt;&lt;STRONG&gt;3- Variation Ending CARR&lt;/STRONG&gt; = this is the monthly sale.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4- Ending CARR&lt;/STRONG&gt; =&lt;BR /&gt;if IsFirstMonth = 1,&lt;BR /&gt;[OB Initial] + [Variation Ending CARR ]&lt;BR /&gt;else&lt;BR /&gt;[OB Adjusted] + [Variation Ending CARR ]&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;This is where the issue is.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;IF(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;_IsFistMonth = 1 &amp;amp;&amp;amp; SELECTEDVALUE(Activitylist[Year]) = _SelectedYear,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;[OB Initial] + [Variation Ending CARR], // For the first month, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;CALCULATE(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;[OB Initial] + [Variation Ending CARR] // &lt;EM&gt;i&lt;STRONG&gt;t should be [OB Adjusted] + [Variation Ending CARR ] but it is showing circular dependency error.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have tried different ways but issue is still there.&lt;BR /&gt;Need help to fix this.&lt;BR /&gt;PBIX with dummy data can be downloaded here &amp;gt;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1oaD8-4JRjDGqKreyCSQjPWndl8NKwxYE/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1oaD8-4JRjDGqKreyCSQjPWndl8NKwxYE/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 16:45:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4007400#M156957</guid>
      <dc:creator>kmax</dc:creator>
      <dc:date>2024-06-24T16:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Circular dependency error</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4008731#M157391</link>
      <description>&lt;P&gt;Hi,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="466178" data-lia-user-login="kmax" class="lia-mention lia-mention-user"&gt;kmax&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Regarding the issue you raised, my solution is as follows:&lt;/P&gt;
&lt;P style="margin: 0in; font-size: 12.0pt; color: black;"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;1.Based on the pbix file you provided, we infer that the reason you have a circular dependency problem is because you referenced [Ending CARR Measure] in your [OB Adjusted] me&lt;/SPAN&gt;&lt;SPAN&gt;asure&lt;/SPAN&gt;&lt;SPAN&gt;, However, [OB Adjusted] is cited in [Ending CARR Measure], resulting in cyclic dependence.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P style="margin-top: 0pt; margin-bottom: 8pt; font-family: Aptos; font-size: 12.0pt;"&gt;&lt;A href="https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Recursion-in-DAX/m-p/2633314" target="_blank"&gt;&lt;SPAN&gt;Solved: Recursion in DAX - Microsoft Fabric Community&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin-top: 0pt; margin-bottom: 8pt; font-family: Aptos; font-size: 12.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;2.You can try doing the calculation in excel first and then importing it into power bi. This is by far the easiest way.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Here are links to the relevant documents:&lt;/P&gt;
&lt;P style="margin-top: 0pt; margin-bottom: 6pt; font-family: Aptos; font-size: 12.0pt;"&gt;&lt;A href="https://spreadsheetweb.com/how-to-create-recursive-functions-in-excel/" target="_blank"&gt;&lt;SPAN&gt;How to create recursive functions in Excel with LAMBDA (spreadsheetweb.com)&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;3.You can also implement this functionality in powerquery, but you need to put a little more effort into it:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Here are links to the relevant documents:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Aptos; font-size: 12.0pt;"&gt;&lt;A href="https://mentor.enterprisedna.co/queries/recursive-functions-in-power-query" target="_blank"&gt;Recursive Functions in Power Query | Power BI Data (enterprisedna.co)&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;SPAN&gt;helps&lt;/SPAN&gt;, then please consider Accept it &lt;SPAN&gt;as the solution &lt;/SPAN&gt;to help the other members find it more quickly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 08:45:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4008731#M157391</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T08:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Circular dependency error</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4008814#M157399</link>
      <description>&lt;P&gt;Hi Lu,&lt;BR /&gt;Thanks for the details.&lt;/P&gt;&lt;P&gt;The requirement is to do all the calculations in PowerBI to reduce dependence on Excel. So, should I assume that this is something not possible using DAX?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 09:23:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4008814#M157399</guid>
      <dc:creator>kmax</dc:creator>
      <dc:date>2024-06-25T09:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Circular dependency error</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4009002#M157432</link>
      <description>&lt;P&gt;Hi,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="466178" data-lia-user-login="kmax" class="lia-mention lia-mention-user"&gt;kmax&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your quick reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Yes, your assumption is correct.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;if your requirements involve recursion, recursion cannot be achieved with dax alone.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Of course, if you have other new discoveries, you are welcome to share with us.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;SPAN&gt;helps&lt;/SPAN&gt;, then please consider Accept it &lt;SPAN&gt;as the solution &lt;/SPAN&gt;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 11:36:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4009002#M157432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T11:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Circular dependency error</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4032432#M159534</link>
      <description>&lt;P&gt;Hi &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;v-linyulu-msft&lt;/SPAN&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Here is the updated PBIX.&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/1Wk4WppXQGYzpSMcIpRiqgYMB0l9TGEHz/view?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1Wk4WppXQGYzpSMcIpRiqgYMB0l9TGEHz/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Still facing issues but I have managed to get the value of previous month as the next month opening balance.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I have found two ways to tackle circular dependancy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Option 1 - using calculated column&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The ending Balance column is working fine till 4th month.&lt;BR /&gt;From 5th month, the ending balance is showing wrong value.&lt;BR /&gt;2024-03&lt;BR /&gt;Ending Balance column = 1893980&lt;BR /&gt;2024-04&lt;BR /&gt;Month sale column = -65471&lt;/P&gt;&lt;P&gt;2024-04 Ending balance =&lt;/P&gt;&lt;P&gt;1893980-65471=1828509 (correct value)&lt;BR /&gt;but it is showing 2055416.&lt;BR /&gt;if we subtract&lt;BR /&gt;1828509-2055416 = -226907 (this is month sale value of 2024-01.&lt;BR /&gt;same pattern continues for rest of the months of any year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Option 2 - using measures&lt;/STRONG&gt;&lt;BR /&gt;from 2nd month onward, the Opening Balance adjusted value is correctly fetching from closing balance measure value of previous month.&lt;BR /&gt;but the closing balance measure is showing wrong answer for all months.&lt;BR /&gt;it is doing&lt;BR /&gt;opening balance + monthly variation = closing balance measure&lt;BR /&gt;this is fine for 1st month. From 2nd month, it should set the opening balance value from closing balance of previous month but it is using the 1st month value of opening balance for all months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set Option 1 and Option 2 titles for both matrix for ease in the new PBIX.&lt;BR /&gt;Now, I am facing issue in getting the correct sum using both the options.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 11:15:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Circular-dependency-error/m-p/4032432#M159534</guid>
      <dc:creator>kmax</dc:creator>
      <dc:date>2024-07-09T11:15:29Z</dc:date>
    </item>
  </channel>
</rss>

