Example: Transform Field Values using an Expression

This is a follow on topic, continuing onward from the preceding example of Copy one Column into Another Column using Transform and using the same data.   We continue using the Expressions template in the  Transform pane to change the values of fields.   We show an example changing the price of selected products.

 

We continue from the previous example.

 

 

Recall that we had two products selected in the table.   If the Transform pane is not in sight we launch the Transform pane.

 

With the focus on the table window, in the Transform pane we choose the Unit Price field, and then we double-click the Expressions template to launch it in the Transform dialog.

 

 

Check the Transform selection only box, to restrict application of the transform to only selected records.   

 

 

When working with selections, it is a good idea to begin by checking the Transform selection only box before specifying other parameters, in case we forget to do that later.

 

Press the Edit Expression button to launch the expression builder dialog.

 

 

In the lower pane of the expression builder dialog, we double-click on the Unit Price field in the table scheme to automatically add the field name to the expression pane.   In the upper pane we continue to write the expression by manually keyboarding the text * 1.1 to form the expression:

 

[Unit Price] * 1.1

 

That means we are telling Manifold to multiply the value of the Unit Price field by 1.1.  

 

Press OK to return to the Transform pane.

 

 

In the Transform pane, for the Result destination we leave the default Same Field choice in place.  That will write the result of the computation back into the Unit Price field, updating it in place.

 

Since we have checked the Transform selection only box, only selected records will be altered.

 

Press Transform.

 

 

The table immediately updates to multiply the Unit Price values for selected records by 1.1,  increasing the unit price by 10% for the two selected records.

Example: Transform Field Values using Multiply

In the prior example we used the Expression template.  In this example we will use the Arithmetic : multiply transform operation to accomplish the same task, increasing prices for selected records.  

 

Using Ctrl-Click we select two records in the Products table,   We will increase the Unit Price for these two of Chef Anton's products   The Unit Price is 24.2 for the first product and 21.35 for the second product.  

 

We will use the Transform pane to modify the Unit Price field.

 

 

With the focus on the Products table window, in the Transform pane we choose the Unit Price field, and then we double-click the Arithmetic template to launch it in the Transform dialog.

 

 

Check the Transform selection only box, to restrict application of the transform to only selected records.   

 

 

When working with selections, it is a good idea to begin by checking the Transform selection only box before specifying other parameters, in case we forget to do that later.

 

In the Arithmetic template, we choose multiply (*) as the Operation.   We enter 1.15 in the Value box.

 

For the Result destination we leave the default Same Field choice in place.  That will write the result of the computation back into the Unit Price field, updating it in place.

 

Since we have checked the Transform selection only box, only selected records will be altered.

 

Press Transform.

 

 

The table immediately updates to multiply the Unit Price values for selected records by 1.15,  increasing the unit price by 15% for the two selected records.

 

See Also

Selection

 

Select Pane

 

Transform Pane

 

Command Window

 

Queries

 

Example: Two Drawings from the Same Table - Take a table with a geom field that is visualized by a drawing.  Add a second geom field to the table and create an rtree index on that field so it can be visualized by a drawing.   Copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field.

 

Example: Construct JSON String using Select and Transform - Use the Select pane and the Transform pane to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.

 

Example: Copy one Column into Another Column with Transform - How to use the Transform pane to copy the contents of one column in a table into another column, but only for selected records.  Uses the Products table from the Nwind example data set.  

 

Example: Use a Transform Expression to Create Buffers in a Drawing - Use the Expression template in the Transform pane to create three different sizes of buffers for different lines in a drawing and then automatically create a query which does the same thing.  Includes examples of saving results to a new component and also the Edit Query button.

 

Example: Clip Areas with a Transform Expression - Use the Expression template in the Transform pane to clip areas in a drawing to fit within horizontal bounds.   Includes examples of saving results to a new component and also the Edit Query button.

 

Example: Simplify Lines with a Transform Expression - Use the Expression template in the Transform pane to make lines smoother in a drawing so that longer lines are smoothed more.  Includes examples of using the Edit Query button to show how different queries are created automatically depending on if we want to update a field or to add a new component.

 

Example: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform pane, seeing what it does in a preview, looking at the query Manifold creates and then trying out the function in the Expression tab.