cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
GroupSquareWolf
Level III

Conditional formula

In the following table, I would like to create a column in which each "Sample" value is divided by the average of "Control" grouped by X.

For examples, each "Sample" in "X1" will be divided by average of "Control" from "X1", each "Sample" in "X2" will be divided by average of "Control" from "X2".

I can get the mean of "Control" by creating a formula that calculates Col Mean grouped by "X" and "Type". 

GroupSquareWolf_1-1651617215248.png

 

How can I create a formula that spits out the averages of "Control" for all the rows within each "X" value? In this case 10 for all the rows contain X1, and 1000 for all the rows contain X2.

 

 

GroupSquareWolf_0-1651616021700.png

 

The data file is attached. 

Thank you for your help!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Conditional formula

Hi GroupSquareWolf-

 

I love working with these types of formula columns, they are like puzzles!

 

Here is a formula that works for your example. It essentially does the same thing that your multiple columns do, but in a single column. It only uses the Y, X, and Type columns without having to build any additional calculation or counter columns.

 

I am sure there are other solutions out there but here is the one I came up with:

 

scott_allen_1-1651667980111.png

 

scott_allen_2-1651668342557.png

 

It is saved as "New Formula" in the data table.

 

Hope this helps!

 

-Scott

 

 

 

-Scott

View solution in original post

3 REPLIES 3
GroupSquareWolf
Level III

Re: Conditional formula

I got what I wanted indirectly, but would still appreciate to know a more direct way to do it.

 

This was what I did

1. I created a conditional formula in :"Type ID", assigning "Sample" as 0 and "Control" as 1

2 . Then multiplied "Type ID" with :"Mean Y by X and Type"

3.  created a new column to fill every row with ColMax grouped by "X"

GroupSquareWolf_0-1651638049211.png

 

Re: Conditional formula

Hi GroupSquareWolf-

 

I love working with these types of formula columns, they are like puzzles!

 

Here is a formula that works for your example. It essentially does the same thing that your multiple columns do, but in a single column. It only uses the Y, X, and Type columns without having to build any additional calculation or counter columns.

 

I am sure there are other solutions out there but here is the one I came up with:

 

scott_allen_1-1651667980111.png

 

scott_allen_2-1651668342557.png

 

It is saved as "New Formula" in the data table.

 

Hope this helps!

 

-Scott

 

 

 

-Scott
GroupSquareWolf
Level III

Re: Conditional formula

Thank you very much! It is very helpful.