<?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 How to create a column that counts the total specified values form other columns? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409890#M65964</link>
    <description>&lt;P&gt;It's easy to do this one in Excel with the "countif" function but, How can define a column that counts the total specified values from other columns?&lt;/P&gt;&lt;P&gt;example: I have a table of the total answers, how can I count the right answer for each question?&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;question&lt;/TD&gt;&lt;TD&gt;student 1&lt;/TD&gt;&lt;TD&gt;student 2&lt;/TD&gt;&lt;TD&gt;right answer&lt;/TD&gt;&lt;TD&gt;total answer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:35:33 GMT</pubDate>
    <dc:creator>lehoth</dc:creator>
    <dc:date>2023-06-10T23:35:33Z</dc:date>
    <item>
      <title>How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409890#M65964</link>
      <description>&lt;P&gt;It's easy to do this one in Excel with the "countif" function but, How can define a column that counts the total specified values from other columns?&lt;/P&gt;&lt;P&gt;example: I have a table of the total answers, how can I count the right answer for each question?&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;question&lt;/TD&gt;&lt;TD&gt;student 1&lt;/TD&gt;&lt;TD&gt;student 2&lt;/TD&gt;&lt;TD&gt;right answer&lt;/TD&gt;&lt;TD&gt;total answer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:35:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409890#M65964</guid>
      <dc:creator>lehoth</dc:creator>
      <dc:date>2023-06-10T23:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409923#M65965</link>
      <description>&lt;P&gt;Here is one way to create the formula for this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Sum( :student 1 == :right answer, :student 2 == :right answer )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Aug 2021 07:19:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409923#M65965</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-16T07:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409926#M65966</link>
      <description>&lt;P&gt;Many was to do this in JMP but they do differ from excel because &lt;A href="https://community.jmp.com/t5/Discussions/JMP-is-Not-a-Spreadsheet/m-p/214307#M42848" target="_blank" rel="noopener"&gt;JMP isn't a spreadsheet.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some examples with formulas:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Items(Loc(Words(:"student 1"n || :"student 2"n, ""), :"right answer"n));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Items(Loc(Current Data Table()[row(), {"student 1", "student 2"}], :"right answer"n))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datatables: Stack table with student columns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1629097997023.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35040i3588370011DF24E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1629097997023.png" alt="jthi_0-1629097997023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Add formula to check differences between answer and and right answer:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1629098080884.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35041iB3EDCE24FA904686/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1629098080884.png" alt="jthi_1-1629098080884.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Formula for Column 5:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(:right answer == :Data,
	1,
	0
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Create tabulate/summary (you might have to change the modeling type of question to Nominal or Ordinal):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1629098123819.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35042iBF5236DE34734348/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1629098123819.png" alt="jthi_2-1629098123819.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="jthi_3-1629098144883.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35043iEB3DD855B9C25855/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1629098144883.png" alt="jthi_3-1629098144883.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>Mon, 16 Aug 2021 07:25:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/409926#M65966</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-08-16T07:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410084#M65985</link>
      <description>&lt;P&gt;what if I have many students, I tried to do a for loop based on your suggestion, but I couldn't get it.&lt;/P&gt;&lt;P&gt;(I also collect in other classes)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lehoth_0-1629122211708.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35065iFD01295E321229F1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lehoth_0-1629122211708.png" alt="lehoth_0-1629122211708.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 13:59:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410084#M65985</guid>
      <dc:creator>lehoth</dc:creator>
      <dc:date>2021-08-16T13:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410126#M65989</link>
      <description>&lt;P&gt;Let's start with this table (total_answers is there just to show correct amount):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1629125443471.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35066iD8A36756920789CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1629125443471.png" alt="jthi_0-1629125443471.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;1. Stack&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1629125490967.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35067i55FFFCB1380263A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1629125490967.png" alt="jthi_1-1629125490967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. Add formula (Column 6):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1629125531212.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35069i949A50746656E8A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1629125531212.png" alt="jthi_3-1629125531212.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;3. Tabulate (or summary):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_4-1629125579642.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35070i729433FB1E6F97E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_4-1629125579642.png" alt="jthi_4-1629125579642.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Also take care that the column Data Types and Modeling Types are correct for the data you are modeling.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example table with a bit more advanced formula which I wouldn't suggest using until you learn a bit more about JSL:&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);

dt = New Table("Untitled 4",
	Add Rows(5),
	Set Header Height(50),
	New Column("question", Numeric, "Ordinal", Format("Best", 12), Set Values([1, 2, 3, 4, 5])),
	New Column("student1", Character, "Nominal", Set Values({"A", "A", "A", "A", "A"})),
	New Column("student2", Character, "Nominal", Set Values({"A", "B", "B", "B", "A"})),
	New Column("student3", Character, "Nominal", Set Values({"A", "B", "C", "C", "A"})),
	New Column("student4", Character, "Nominal", Set Values({"A", "B", "C", "D", "A"})),
	New Column("student5", Character, "Nominal", Set Values({"A", "B", "C", "D", "A"})),
	New Column("right_answer", Character, "Nominal", Set Values({"A", "B", "C", "D", "E"}))
);


//Don' use if you don't have clear understanding what this does! Try first using data table method
//2::5 indicates indices of student result columns
dt &amp;lt;&amp;lt; New Column("Total_answers", Numeric, Continuous, 
	&amp;lt;&amp;lt; Formula(
		N Items(Loc(Current Data Table()[Row(), 2::6], :right_answer))
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 14:56:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410126#M65989</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-08-16T14:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a column that counts the total specified values form other columns?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410189#M65994</link>
      <description>thank you very much, Mr.Jthi ^^</description>
      <pubDate>Mon, 16 Aug 2021 16:17:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-column-that-counts-the-total-specified-values/m-p/410189#M65994</guid>
      <dc:creator>lehoth</dc:creator>
      <dc:date>2021-08-16T16:17:03Z</dc:date>
    </item>
  </channel>
</rss>

