Skip to main content
Completed

Provide code example when creating an Expression, Calculated or Calculation (Function) column

Related products:Software Factory

Mark Jongeling
Administrator

When creating a table column that has a calculation type, it is necessary to write some code. Based on the type, the structure of the code will be different from one and other. Such like Expression columns, you can make use of the “T1.” alias, which is the table itself, whilst Calculated columns cannot use this.

Just like the code example in Control procedure for SQL-typed CP's, I would like a short example that shows me as a developer what I can (and cannot) use as code.  

Example: 

  • Expression: 
    concat_ws(' ', t1.first_name, t1.last_name)  --Thanks @Robbert :)

     

  • Calculated:
    (100.0 + tax_percentage) / 100.0

     

  • Calculated (function): 
    select sum(order_total) from sales_order where sales_order_id = @sales_order_id

     

Did this topic help you find an answer to your question?

8 replies

Robert Jan de Nie
Thinkwise blogger
Forum|alt.badge.img+5

Great idea! I always get the proxy function wrong! 


Robbert van Tongeren
Thinkwise blogger

Great!
1 small addition: instead of

concat(t1.first_name, ' ' + t1.last_name)

I would use

concat_ws(' ',t1.first_name,t1.last_name)

Because the concat_ws will already exclude null values with the seperator. :)


Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
NewOpen

Arie V
Community Manager
Forum|alt.badge.img+12
  • Community Manager
  • 999 replies
  • August 31, 2022

Great idea indeed!


Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
OpenOn the backlog

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Author
  • Administrator
  • 3945 replies
  • July 14, 2023
On the backlogWorking on it!

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Author
  • Administrator
  • 3945 replies
  • July 14, 2023
Working on it!Next release
 

To explain the subtle differences between the query structure for calculated field types, a code example will be added to the query field when using a calculation type for a column. Switching between calculated field types will overwrite the present example if possible.

Image

 
 
 
 

Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
Next releaseCompleted

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings