<?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: Converting time to time intervals and resetting based on second column values to prevent x-axis offset in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879861#M104329</link>
    <description>&lt;P&gt;See if this does what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "ElapsedTime", numeric, continuous, Formula( :LocalTime - Col Min( :Local Time, :Name ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Jun 2025 20:19:47 GMT</pubDate>
    <dc:creator>mmarchandFSLR</dc:creator>
    <dc:date>2025-06-13T20:19:47Z</dc:date>
    <item>
      <title>Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879851#M104328</link>
      <description>&lt;P&gt;I have a data table with the columns "Time" (Numeric, continuous, formatted in 12-hr h:m:s) and "Name" (Character, just a list of the experiment to which each time point is associated). When I graph using other columns not mentioned here as the Y-axis, and Time as the x-axis, the issue arises where each plot between x-grouping variables is shifted since the x-axis scale remains the same between x-grouping variables (Figure 1).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="x vs y.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76914iF82AE955115CC175/image-size/large?v=v2&amp;amp;px=999" role="button" title="x vs y.png" alt="x vs y.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Figure 1. Each x-grouping variable is a "Name" column variable with "Name also as the Overlay.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My thought is to write a script to:&lt;/P&gt;
&lt;P&gt;1. Create a new column&lt;/P&gt;
&lt;P&gt;2. Code new column with a formula that converts the "Time" column to time in seconds, starting at "0" and counting up with a specified interval (2 seconds in this case), resetting to 0 as soon as the "Name" column changes values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My main questions are:&lt;/P&gt;
&lt;P&gt;1. Is this possible?&lt;/P&gt;
&lt;P&gt;2. Is there an easier way to do this without making a new column?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently on JMP 17.2.0 on Windows 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 20:02:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879851#M104328</guid>
      <dc:creator>polymerist</dc:creator>
      <dc:date>2025-06-13T20:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879861#M104329</link>
      <description>&lt;P&gt;See if this does what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "ElapsedTime", numeric, continuous, Formula( :LocalTime - Col Min( :Local Time, :Name ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jun 2025 20:19:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879861#M104329</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2025-06-13T20:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879863#M104330</link>
      <description>&lt;P&gt;Thanks for the reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, that returns the column "Elapsed Time" seen in the figure below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="testColumns.png" style="width: 138px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76915iE53177E7AC800D91/image-size/large?v=v2&amp;amp;px=999" role="button" title="testColumns.png" alt="testColumns.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following code, which yielded the column, "Time (s)" in the figure above as well. Seems like it's doing the set inititial to zero function, but not converting anything else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);  // Ensure scope is local for column references
dt = Current Data Table(); // Reference to the active data table

// Add a new numeric column "Time (s)" with the specified formula
dt &amp;lt;&amp;lt; New Column( "Time (s)",
    Numeric, Continuous, Format( "Best", 12 ),  // numeric format (optional)
    Formula(
        If(
            Row() == 1,
            // Case 1: First row of the table -&amp;gt; start at 0 seconds
            0,
            :Name("Name") != Lag( :Name("Name") ),
            // Case 2: Identifier changed from the previous row -&amp;gt; new run, reset time to 0
            0,
            // Case 3: Otherwise (same run as previous row) -&amp;gt; accumulate time difference
            Lag( :Name("Time (s)") ) + ( :LocalTime - Lag( :LocalTime ) )
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 20:37:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879863#M104330</guid>
      <dc:creator>polymerist</dc:creator>
      <dc:date>2025-06-13T20:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879876#M104331</link>
      <description>&lt;P&gt;There may be something unexpected about your :LocalTime column.&amp;nbsp; I tried my formula on a made-up table, and it worked as intended.&amp;nbsp; How is your :LocalTime column formatted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmarchandFSLR_0-1749849195908.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76917iB26D715F559D4C8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmarchandFSLR_0-1749849195908.png" alt="mmarchandFSLR_0-1749849195908.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmarchandFSLR_0-1749849265020.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76918i9BEBFFF8B4E18D74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmarchandFSLR_0-1749849265020.png" alt="mmarchandFSLR_0-1749849265020.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:14:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879876#M104331</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2025-06-13T21:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879879#M104332</link>
      <description>&lt;P&gt;I created an example data table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1749849195267.png" style="width: 348px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76916i62BB5DBAF10D2127/image-dimensions/348x834?v=v2" width="348" height="834" role="button" title="txnelson_0-1749849195267.png" alt="txnelson_0-1749849195267.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And then I ran the following JSL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);  // Ensure scope is local for column references
dt = Current Data Table(); // Reference to the active data table

// Add a new numeric column "Time (s)" with the specified formula
dt &amp;lt;&amp;lt; New Column( "Time (s)",
    Numeric, Continuous, Format( "Best", 12 ),  // numeric format (optional)
    Formula(
        If(
            Row() == 1,
            // Case 1: First row of the table -&amp;gt; start at 0 seconds
            0,
            :Name("Name") != Lag( :Name("Name") ),
            // Case 2: Identifier changed from the previous row -&amp;gt; new run, reset time to 0
            0,
            // Case 3: Otherwise (same run as previous row) -&amp;gt; accumulate time difference
            Lag( :Name("Time (s)") ) + ( :LocalTime - Lag( :LocalTime ) )
        )
    )
)
dt &amp;lt;&amp;lt; New Column( "ElapsedTime", numeric, continuous, Formula( :LocalTime - Col Min( :Local Time, :Name ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;An got the following output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1749849284940.png" style="width: 549px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76919iFD0618F5B108F1FF/image-dimensions/549x753?v=v2" width="549" height="753" role="button" title="txnelson_1-1749849284940.png" alt="txnelson_1-1749849284940.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:15:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879879#M104332</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-06-13T21:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879881#M104333</link>
      <description>&lt;P&gt;Okay, nevermind, the code I posted actually worked! I had my column name misspelled :confounded_face:&lt;/img&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only remaining question then would be, i&lt;SPAN&gt;s there an easier way to do this without making a new column?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:21:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879881#M104333</guid>
      <dc:creator>polymerist</dc:creator>
      <dc:date>2025-06-13T21:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879884#M104335</link>
      <description>&lt;P&gt;It requires a new column.&amp;nbsp; It doesn't have to be a persistent column, meaning it could be a column that exists only while the graph is there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Transform Column(
		"Time (s)",
		Formula( :LocalTime - Col Min( :LocalTime, :Name ) )
	),
	Show Control Panel( 0 ),
	Variables( X( :"Time (s)"n ), Y( :Y Column ), Group X( :Name ) ),
	Elements( Smoother( X, Y, Legend( 8 ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:32:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879884#M104335</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2025-06-13T21:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879886#M104336</link>
      <description>&lt;P&gt;You can always use a Transform (virtual) column when you run your Graph Builder.&amp;nbsp; That way you do not have to have an actual column in your data table.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:37:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879886#M104336</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-06-13T21:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879890#M104337</link>
      <description>&lt;P&gt;This is perfect. Thank you and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;both for the great solutions!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 21:56:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879890#M104337</guid>
      <dc:creator>polymerist</dc:creator>
      <dc:date>2025-06-13T21:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Converting time to time intervals and resetting based on second column values to prevent x-axis offset</title>
      <link>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879922#M104343</link>
      <description>&lt;P&gt;As an incidental side note, the standard in JMP is to place the units of measurement in to the Units Column Property.&amp;nbsp; In your case the difference would be that the actual column name would be Time, however, by default, the Units value is displayed between a set of parentheses, changing the displayed value as Time (s)&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jun 2025 01:01:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Converting-time-to-time-intervals-and-resetting-based-on-second/m-p/879922#M104343</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-06-14T01:01:30Z</dc:date>
    </item>
  </channel>
</rss>

