<?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 Cycle Detected in calculation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322464#M57258</link>
    <description>&lt;P&gt;I know JMP is not a spreadsheet and I might need to calculate this differently than I would in excel, but I cannot figure out the workaround.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a calculation where a variable is relying on itself and that gives me a "cycle detected for data column" error&lt;/P&gt;&lt;P&gt;I have a tank that has solution being added in over time. I know how much I have added and the tank's total volume. I also take volume out of the tank at sample times. I need to calculate how much of solution A is being removed with each sample volume. But I can't figure out how to do that without getting this cycle error. Please help!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	New Column( "Soln A Removed in Current Draw (mL)",
		Numeric,
		"Continuous",
		Formula(
			:Name( "Soln A concentration before draw (mL/L)" ) * (
			:Name( "Manually Recorded Sample Volume (mL)" ) / 1000)
		),
	);
	New Column( "Soln A concentration before draw (mL/L)",
		Numeric,
		"Continuous",
		Formula(
			If(
				(:Name( "Soln A added (mL)" ) 
				/
				:Name( "Culture Volume Pre-Drawdown (mL)" )
				) 
				* 1000,
				(
					(
						:Name( "Soln A added (mL)" )
						-
						Lag(
							:Name( "Cumulative Soln A Removed (mL)" ), 1 
						)	
					) 				
				/
				:Name( "Culture Volume Pre-Drawdown (mL)" )
					
				) * 1000
			)
		),
	);
	New Column( "Cumulative Soln A Removed (mL)",
		Numeric,
		"Continuous",
		Formula(
			Col Cumulative Sum(
				:Name( "Soln A Removed in Current Draw (mL)" ),
				:Batch Number
			)
		),
	);
	New Column( "Soln A added per current Tank Volume (mL/L)",
		Numeric,
		"Continuous",
		Formula(
			(:Name( "Soln A added (mL)" ) * 1000) /
			:Name( "Culture Volume Pre-Drawdown (mL)" )
		),
	);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:20:35 GMT</pubDate>
    <dc:creator>ealindahl</dc:creator>
    <dc:date>2023-06-10T23:20:35Z</dc:date>
    <item>
      <title>Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322464#M57258</link>
      <description>&lt;P&gt;I know JMP is not a spreadsheet and I might need to calculate this differently than I would in excel, but I cannot figure out the workaround.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a calculation where a variable is relying on itself and that gives me a "cycle detected for data column" error&lt;/P&gt;&lt;P&gt;I have a tank that has solution being added in over time. I know how much I have added and the tank's total volume. I also take volume out of the tank at sample times. I need to calculate how much of solution A is being removed with each sample volume. But I can't figure out how to do that without getting this cycle error. Please help!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	New Column( "Soln A Removed in Current Draw (mL)",
		Numeric,
		"Continuous",
		Formula(
			:Name( "Soln A concentration before draw (mL/L)" ) * (
			:Name( "Manually Recorded Sample Volume (mL)" ) / 1000)
		),
	);
	New Column( "Soln A concentration before draw (mL/L)",
		Numeric,
		"Continuous",
		Formula(
			If(
				(:Name( "Soln A added (mL)" ) 
				/
				:Name( "Culture Volume Pre-Drawdown (mL)" )
				) 
				* 1000,
				(
					(
						:Name( "Soln A added (mL)" )
						-
						Lag(
							:Name( "Cumulative Soln A Removed (mL)" ), 1 
						)	
					) 				
				/
				:Name( "Culture Volume Pre-Drawdown (mL)" )
					
				) * 1000
			)
		),
	);
	New Column( "Cumulative Soln A Removed (mL)",
		Numeric,
		"Continuous",
		Formula(
			Col Cumulative Sum(
				:Name( "Soln A Removed in Current Draw (mL)" ),
				:Batch Number
			)
		),
	);
	New Column( "Soln A added per current Tank Volume (mL/L)",
		Numeric,
		"Continuous",
		Formula(
			(:Name( "Soln A added (mL)" ) * 1000) /
			:Name( "Culture Volume Pre-Drawdown (mL)" )
		),
	);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:20:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322464#M57258</guid>
      <dc:creator>ealindahl</dc:creator>
      <dc:date>2023-06-10T23:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322483#M57259</link>
      <description>&lt;P&gt;You are correct. JMP is not a spreadsheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might think of a JMP data table as a collection of observations (i.e., data set). As such, each change in volume is a new row. So you might have one column to represent the volume added or removed and another to represent the current volume.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the first column, Solution A Removed in Current Draw, should be a value that is entered, not computed. That might break the cyclical references. Possibly the same for the last column, Solution A Added in Current Draw. Adjust the formulas accordingly.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 16:58:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322483#M57259</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-10-16T16:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322484#M57260</link>
      <description>&lt;P&gt;Yea it would be great if I could enter the amount removed, but I would only know the amount removed based on the current concentration which, you can see, also relies on the amount removed previously.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 17:10:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322484#M57260</guid>
      <dc:creator>ealindahl</dc:creator>
      <dc:date>2020-10-16T17:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322812#M57267</link>
      <description>&lt;P&gt;Here is a different take on the problem.&amp;nbsp; I couldn't completely test it, given the data you provided, but I think you will see the approach I am taking, and you should be able to build upon it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dt &amp;lt;&amp;lt; New Column( "Soln A Removed in Current Draw (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A concentration before draw (mL/L)" );
dt &amp;lt;&amp;lt; New Column( "Cumulative Soln A Removed (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A added per current Tank Volume (mL/L)" );


For Each Row( 

// Soln A added per current Tank Volume (mL/L)
	:Name( "Soln A added per current Tank Volume (mL/L)" )  = (:Name( "Soln A added (mL)" )  * 1000) /
	:Name( "Culture Volume Pre-Drawdown (mL)" ) ;
	
// Soln A concentration before draw (mL/L)	
	If( :Name( "Soln A added (mL)" )  / :Name( "Culture Volume Pre-Drawdown (mL)" )  * 1000,
		:Name( "Soln A concentration before draw (mL/L)" )  = :Name( "Soln A added (mL)" ) 
		-Lag( :Name( "Cumulative Soln A Removed (mL)" )  ) / :Name( "Culture Volume Pre-Drawdown (mL)" )  *
		1000
	);

// Soln A Removed in Current Draw (mL)
	:Name( "Soln A Removed in Current Draw (mL)" )  = :Name( "Soln A concentration before draw (mL/L)" )  *
	(:Name( "Manually Recorded Sample Volume (mL)" )  / 1000);

// Cumulative Soln A Removed (mL)
	curBatch = :Batch Number ;
	curRow = Row();
	:Name( "Cumulative Soln A Removed (mL)" )  = Sum(
		:Name( "Soln A Removed in Current Draw (mL)" )[dt &amp;lt;&amp;lt; get rows where(
			:Batch Number == curBatch &amp;amp; Row() &amp;lt;= curRow
		)]
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 19:00:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/322812#M57267</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-16T19:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/323628#M57323</link>
      <description>&lt;P&gt;I tried your method on a slightly different table (i only added the bach number column, but I think the issue is still there. Instead of an error message I get blank cells. Is there any workaround to allow a variable to rely on its last value?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dt &amp;lt;&amp;lt; New Column( "Soln A Removed in Current Draw (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A concentration before draw (mL/L)" );
dt &amp;lt;&amp;lt; New Column( "Cumulative Soln A Removed (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A added per current Tank Volume (mL/L)" );


For Each Row( 

// Soln A added per current Tank Volume (mL/L)
	:Name( "Soln A added per current Tank Volume (mL/L)" )  = (:Name( "Soln A added (mL)" )  * 1000) /
	:Name( "Culture Volume Pre-Drawdown (mL)" ) ;
	
// Soln A concentration before draw (mL/L)	
	If( :Name( "Soln A added (mL)" )  / :Name( "Culture Volume Pre-Drawdown (mL)" )  * 1000,
		:Name( "Soln A concentration before draw (mL/L)" )  = :Name( "Soln A added (mL)" ) 
		-Lag( :Name( "Cumulative Soln A Removed (mL)" )  ) / :Name( "Culture Volume Pre-Drawdown (mL)" )  *
		1000
	);

// Soln A Removed in Current Draw (mL)
	:Name( "Soln A Removed in Current Draw (mL)" )  = :Name( "Soln A concentration before draw (mL/L)" )  *
	(:Name( "Manually Recorded Sample Volume (mL)" )  / 1000);

// Cumulative Soln A Removed (mL)
	curBatch = :Batch Number ;
	curRow = Row();
	:Name( "Cumulative Soln A Removed (mL)" )  = Sum(
		:Name( "Soln A Removed in Current Draw (mL)" )[dt &amp;lt;&amp;lt; get rows where(
			:Batch Number == curBatch &amp;amp; Row() &amp;lt;= curRow
		)]
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Oct 2020 19:16:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/323628#M57323</guid>
      <dc:creator>ealindahl</dc:creator>
      <dc:date>2020-10-19T19:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Detected in calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/323708#M57327</link>
      <description>&lt;P&gt;The issue appears to be that the column value for "Soln A concentration before draw (mL/L)" was always getting set to a missing value.&amp;nbsp; In JMP adding together two values where one of them is a missing value always results in a missing value.....which can be over ridden by using the Sum() function.&amp;nbsp; Here are the results I get after the change.&amp;nbsp; The changed JSL is below&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="soln.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/27494i517271E7E8BB181A/image-size/large?v=v2&amp;amp;px=999" role="button" title="soln.PNG" alt="soln.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dt &amp;lt;&amp;lt; New Column( "Soln A Removed in Current Draw (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A concentration before draw (mL/L)" );
dt &amp;lt;&amp;lt; New Column( "Cumulative Soln A Removed (mL)" );
dt &amp;lt;&amp;lt; New Column( "Soln A added per current Tank Volume (mL/L)" );


For Each Row( 

// Soln A added per current Tank Volume (mL/L)
	:Name( "Soln A added per current Tank Volume (mL/L)" ) = (:Name( "Soln A added (mL)" ) * 1000) /
	:Name( "Culture Volume Pre-Drawdown (mL)" );
	
// Soln A concentration before draw (mL/L)	
	If( :Name( "Soln A added (mL)" ) / :Name( "Culture Volume Pre-Drawdown (mL)" ) * 1000,
		:Name( "Soln A concentration before draw (mL/L)" ) = Sum(
			:Name( "Soln A added (mL)" ),
			-1 * Lag( :Name( "Cumulative Soln A Removed (mL)" ) )
		) / :Name( "Culture Volume Pre-Drawdown (mL)" ) * 1000
	);

// Soln A Removed in Current Draw (mL)
	:Name( "Soln A Removed in Current Draw (mL)" ) = :Name( "Soln A concentration before draw (mL/L)" ) * (
	:Name( "Manually Recorded Sample Volume (mL)" ) / 1000);

// Cumulative Soln A Removed (mL)
	curBatch = :Batch Number;
	curRow = Row();
	:Name( "Cumulative Soln A Removed (mL)" ) = Sum(
		:Name( "Soln A Removed in Current Draw (mL)" )[dt &amp;lt;&amp;lt; get rows where( :Batch Number == curBatch &amp;amp; Row() &amp;lt;= curRow )]
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Oct 2020 19:59:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Detected-in-calculation/m-p/323708#M57327</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-19T19:59:00Z</dc:date>
    </item>
  </channel>
</rss>

