<?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: Weighted mean in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/827252#M100874</link>
    <description>I have a database of transactions where each transaction (row) is a different quantity which is a column. I have a different column for price. I’m trying to have my JMP chart be able to dynamically calculate the weighted average of the price no matter which filters I use on the chart (such as country, product, etc.). I’m hoping not to do this in the data table because it would not be dynamic with the chart filters I use. All help is appreciated. Thanks.</description>
    <pubDate>Tue, 14 Jan 2025 04:33:53 GMT</pubDate>
    <dc:creator>karthikulo</dc:creator>
    <dc:date>2025-01-14T04:33:53Z</dc:date>
    <item>
      <title>Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543283#M76240</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GroupSquareWolf_0-1662980821481.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45370i556FC61C6ECB6EDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GroupSquareWolf_0-1662980821481.png" alt="GroupSquareWolf_0-1662980821481.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;In this example, I would like to calculate Column 2 mean based on mean of each Group. Group 3 has two values, and the mean of Group 3 is (3+9)/2= 6. So I would need to get the by-Group&amp;nbsp;&lt;SPAN&gt;column 2 mean : (3+3+(3+9)/2) /3 = 4.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use Tabulate&lt;FONT face="inherit"&gt;&amp;nbsp;or Column Mean (:Column2 ) to get the statistics, each individual column2 values were used &lt;/FONT&gt;separately&lt;FONT face="inherit"&gt;&amp;nbsp;for calculating the mean (3+3+3+9)/4 = 4.5.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GroupSquareWolf_1-1662980979144.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45371i9148F4ACBD81C927/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GroupSquareWolf_1-1662980979144.png" alt="GroupSquareWolf_1-1662980979144.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to get the correct "by-Group" mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:54:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543283#M76240</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2023-06-10T23:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543507#M76245</link>
      <description>&lt;P&gt;I do not really understand which means you are trying to calculate? You want to take the mean of Column 2 by Group? I do no tunderstand how subgroup needs to play into this. Trying a couple of things to see if it does what you need:&lt;/P&gt;&lt;P&gt;1. Create a new column and add this formula:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean( :Column 2, :Group, :Subgroup )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. if you want that same idea but do not need Subgroup to be part of the by:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean( :Column 2, :Group)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(same result because of the unfortunate way you choose your example table)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To match your example calculation&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;(3+3+6) /3 = 4 you would do just the Subgroup column but that does not match your words where you talk about Group:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean( :Column 2, :Subgroup )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I hope that what you are looking for is in here somewhere!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 09:57:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543507#M76245</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2022-09-12T09:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543530#M76250</link>
      <description>&lt;P&gt;I edited my question to make it clearer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 11:14:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543530#M76250</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2022-09-12T11:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543536#M76252</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/36560"&gt;@GroupSquareWolf&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand correctly your topic, here is the solution :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Right-click on your column "Group", select "New Formula Column" and then "Group By".&lt;/LI&gt;&lt;LI&gt;Then right-click on your "Column 2", select "New Formula Column", "Aggregate", "Mean".&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;JMP should give you mean calculated by the variable you have specified as "GroupBy".&lt;BR /&gt;Here by following these two steps, the formula in the column will be the same as the second script option proposed by&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/92"&gt;@pauldeen&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 11:37:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543536#M76252</guid>
      <dc:creator>Victor_G</dc:creator>
      <dc:date>2022-09-12T11:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543566#M76256</link>
      <description>&lt;P&gt;To get what you want, I would calculate the values outside of Tabulate, and then just use Tabulate for the formatting.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1662987867713.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45373iEE1CF115270E0668/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1662987867713.png" alt="txnelson_0-1662987867713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Sample",
	Add Rows( 4 ),
	New Column( "Group", Numeric, "Ordinal", Format( "Best", 12 ), Set Values( [1, 2, 3, 3] ) ),
	New Column( "Subgroup", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 1, 2] ) ),
	New Column( "Column 2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3, 3, 3, 9] ) )
);

dtSum1 =dt &amp;lt;&amp;lt; Summary(
	Group( :Group ),
	Mean( :Column 2 ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

dtSum2 = dtSum1 &amp;lt;&amp;lt; Summary(
	Mean( :Column 2 ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
dtSum2:Column 2 &amp;lt;&amp;lt; set name( "Column 2_1" );

dtSum1 &amp;lt;&amp;lt; Concatenate( dtSum2, Append to First Table(0));

 dtSum1 &amp;lt;&amp;lt; Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Column Table(
			Grouping Columns( :Group ),
			Statistics( Mean ),
			Analysis Columns( :Column 2 )
		),
		Column Table( Analysis Columns( :Column 2_1 ), Statistics( Mean ) )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Sep 2022 13:05:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543566#M76256</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-09-12T13:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543740#M76265</link>
      <description>&lt;P&gt;So you want the mean of "Column 2" by "Group" --&amp;gt; use tables --&amp;gt; summary:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_0-1663011180523.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45392i0A16C5C26B915662/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_0-1663011180523.png" alt="pauldeen_0-1663011180523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then in the new table that opens take a column mean:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_1-1663011220064.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45393iDADBB03FBCF27952/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_1-1663011220064.png" alt="pauldeen_1-1663011220064.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Result:&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="pauldeen_2-1663011235198.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45394iC0376ECDFF423146/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_2-1663011235198.png" alt="pauldeen_2-1663011235198.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, 12 Sep 2022 19:34:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/543740#M76265</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2022-09-12T19:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/544084#M76296</link>
      <description>&lt;P&gt;Thank you all for your help!!!&lt;/P&gt;&lt;P&gt;The example is a simplified version of what we tried to do with a large data set that has thousands of data points and hundreds of groups. I was hoping that there is a solution without creating an additional data table so that we can keep every thing in the same Data Table, which looks like not an option.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 17:22:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/544084#M76296</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2022-09-13T17:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted mean</title>
      <link>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/827252#M100874</link>
      <description>I have a database of transactions where each transaction (row) is a different quantity which is a column. I have a different column for price. I’m trying to have my JMP chart be able to dynamically calculate the weighted average of the price no matter which filters I use on the chart (such as country, product, etc.). I’m hoping not to do this in the data table because it would not be dynamic with the chart filters I use. All help is appreciated. Thanks.</description>
      <pubDate>Tue, 14 Jan 2025 04:33:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Weighted-mean/m-p/827252#M100874</guid>
      <dc:creator>karthikulo</dc:creator>
      <dc:date>2025-01-14T04:33:53Z</dc:date>
    </item>
  </channel>
</rss>

