<?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 Add one more column based on condition and grouping on other columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449088#M69585</link>
    <description>&lt;P&gt;Hello All,&lt;BR /&gt;Happy new year,&amp;nbsp;&lt;BR /&gt;I stuck at another place, have idea/logic but not able to put into correct formula. Please see the attached image for description. Sample data is also attached.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HSS_1-1641371240772.png" style="width: 536px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38741iB263FCFA4CCC9B20/image-dimensions/536x414?v=v2" width="536" height="414" role="button" title="HSS_1-1641371240772.png" alt="HSS_1-1641371240772.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help?&lt;BR /&gt;Many thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 18:08:15 GMT</pubDate>
    <dc:creator>HSS</dc:creator>
    <dc:date>2023-06-09T18:08:15Z</dc:date>
    <item>
      <title>Add one more column based on condition and grouping on other columns</title>
      <link>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449088#M69585</link>
      <description>&lt;P&gt;Hello All,&lt;BR /&gt;Happy new year,&amp;nbsp;&lt;BR /&gt;I stuck at another place, have idea/logic but not able to put into correct formula. Please see the attached image for description. Sample data is also attached.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HSS_1-1641371240772.png" style="width: 536px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38741iB263FCFA4CCC9B20/image-dimensions/536x414?v=v2" width="536" height="414" role="button" title="HSS_1-1641371240772.png" alt="HSS_1-1641371240772.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help?&lt;BR /&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:08:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449088#M69585</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2023-06-09T18:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Add one more column based on condition and grouping on other columns</title>
      <link>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449324#M69609</link>
      <description>&lt;P&gt;Hi HSS&lt;/P&gt;&lt;P&gt;I think there are 3 steps need to do to get your want.&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Summarize your data table to map. Index is 'sensor' and Values are 'max(Inlet), max(Reture)'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;//You can use below JSL to summarzie a new data table&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Data" ) &amp;lt;&amp;lt; Summary(
	Group( :Sensor ),
	Max( :Occurrence ),
	Subgroup( :Name( "Sub-Sensor" ) ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. Input your conditions by if or match. Here I used If and create a new column in summary data table.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	:Name( "Occurrence, Inlet" ) &amp;gt;= 2 &amp;amp; :Name( "Occurrence, Return" ) &amp;gt;= 2, "Both",
	:Name( "Occurrence, Inlet" ) &amp;gt;= 2 &amp;amp; :Name( "Occurrence, Return" ) &amp;lt; 2, "Inlet",
	:Name( "Occurrence, Inlet" ) &amp;lt; 2 &amp;amp; :Name( "Occurrence, Return" ) &amp;gt;= 2, "Return",
	"Empty"
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3. Join two data table together by 'Sensor' and make sure column' result ' include. Then use condition if to make it real.&lt;/P&gt;&lt;P&gt;// Join summary data table to original data table&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Data" ) &amp;lt;&amp;lt; Join(
	With( Data Table( "Data By (Sensor)" ) ),
	Select(
		:ID,
		:Sensor,
		:Name( "Sub-Sensor" ),
		:Occurrence,
		:Required Column,
		:Name( "Required Column -Cause" )
	),
	SelectWith( :Result ),
	By Matching Columns( :Sensor = :Sensor ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;// add formula in column 'Required Column -Cause' as below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	:Name( "Sub-Sensor" ) == "Inlet" &amp;amp; :Result == "Inlet", "Inlet",
	:Name( "Sub-Sensor" ) == "Return" &amp;amp; :Result == "Return", "Return",
	:Name( "Sub-Sensor" ) == "Inlet" | :Name( "Sub-Sensor" ) == "Return" &amp;amp; :Result == "Both", "Both",
	""
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jan 2022 00:31:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449324#M69609</guid>
      <dc:creator>frank_wang</dc:creator>
      <dc:date>2022-01-06T00:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add one more column based on condition and grouping on other columns</title>
      <link>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449634#M69655</link>
      <description>&lt;P&gt;Thanks Frank.&lt;BR /&gt;&lt;BR /&gt;It worked.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 10:09:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-one-more-column-based-on-condition-and-grouping-on-other/m-p/449634#M69655</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-01-07T10:09:08Z</dc:date>
    </item>
  </channel>
</rss>

