Both sides previous revisionPrevious revision | Last revisionBoth sides next revision |
transformations:rule [2021/04/09 00:08] – craigt | transformations:rule [2021/07/18 22:57] – craigt |
---|
\\ | \\ |
=====Description===== | =====Description===== |
This action calculates a new, or replaces an existing, column by using one or several ordered IF...THEN...ELSE conditions. The conditions are checked one by one until a satisfying condition is found. When a satisfying condition is found, the result is calculated and all other conditions are ignored. When no satisfying condition is found, the default calculation is applied.\\ | This action calculates a new column or replaces an existing column, by using one or several ordered IF...THEN...ELSE conditions. The conditions are checked one by one until a satisfying condition is found. When a satisfying condition is found, the result is calculated and all other conditions are ignored. When no satisfying condition is found, the default calculation is applied.\\ |
| |
\\ | \\ |
\\ | \\ |
=====Remarks===== | =====Remarks===== |
The order of conditions is significant as conditions are checked starting from the first (top). Therefore, conditions that come first have priority over conditions that come later. | The order of conditions is significant as conditions are checked starting with the first (top). Therefore, conditions that come first have priority over conditions that come later. |
| |
While the same result can be achieved using an expression with nested [[syntax:functions:if]] functions, the use of Rule action is recommended for clarity, readability, and the ease of rearranging the order.\\ | While the same result can be achieved using an expression with nested [[syntax:functions:if]] functions, the use of Rule action is recommended for clarity, readability, and the ease of rearranging the order.\\ |
| Switzerland | 53716| 48414| 9.87%| | | Switzerland | 53716| 48414| 9.87%| |
| Canada | 45896| 37469| 18.36%| | | Canada | 45896| 37469| 18.36%| |
| \\ |
**Action parameters:** | **Action parameters:** |
>Create new column: Spending | >Create new column: Spending |
>Calculated as: if ([Disposable income] > 40000), then HIGH. | >Calculated as: if ([Disposable income] > 40000), then HIGH. |
>If none of the condition above is met: Default to LOW | >If none of the conditions above is met: Default to LOW |
| \\ |
**Output table:** | **Result table:** |
^Country ^Gross income ^Disposable income ^Compulsory deductions ^Spending ^ | ^Country ^Gross income ^Disposable income ^Compulsory deductions ^Spending ^ |
| United States | 56067| 45582| 18.7%|HIGH | | | United States | 56067| 45582| 18.7%|HIGH | |
| Switzerland | 53716| 48414| 9.87%|HIGH | | | Switzerland | 53716| 48414| 9.87%|HIGH | |
| Canada | 45896| 37469| 18.36%|LOW | | | Canada | 45896| 37469| 18.36%|LOW | |
| |
| \\ |
| ====Community examples==== |
| * [[https://community.easymorph.com/t//1530/2|Import figures in “scientific format”]] ([[https://community.easymorph.com/uploads/short-url/poEu3Fy9uLb9DdlWKAPN4VoS8XU.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 1//; Action position: //2//) |
| * [[https://community.easymorph.com/t//1551/2|How to look up and replace a string of text]] ([[https://community.easymorph.com/uploads/short-url/dvCtD7gg0AHUtXZ7tmQmuHflSYU.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 3//; Action position: //5//) |
| * [[https://community.easymorph.com/t//1686/2|Aggregation of consecutive date ranges]] ([[https://community.easymorph.com/uploads/short-url/xyC5nPd52hGrMiRXjp5w1RVUTYL.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Easymorph Patient Example Data.xlsx//;\\ Action position: //6//) |
| * [[https://community.easymorph.com/t//1697/2|Partial or fuzzy lookup]] ([[https://community.easymorph.com/uploads/short-url/nfnr4o7wX53X2SEaJU5NJ5AzAGt.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Lookup//; Action position: //4//) |
| * [[https://community.easymorph.com/t//1876/2|How to report validation failures?]] ([[https://community.easymorph.com/uploads/short-url/x8xqV8QqQbnnI467dxWdhLbXnFr.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Validate data//; Action position: //2//) |
| |
\\ | \\ |