Iaron7 Posted April 15, 2021 Report Share Posted April 15, 2021 Any simple way to do this in a calculated field? Quote Link to comment Share on other sites More sharing options...
0 CoopperBackpack Posted April 16, 2021 Report Share Posted April 16, 2021 Hello @Iaron7, I am afraid that that there is no ready function in SQL to calculate the greatest common divisor. The solution requires using the loop. So, it looks like this is not possible to calculate the GCD in the Calculated Field. You may find supported function in this article https://howto.caspio.com/function-reference/ As an option, it is possible to make this calculation by the Triggered Actions. The example of the table design: Triggered Action: The output: You may learn more about Triggered Actions in this article if needed https://howto.caspio.com/tables-and-views/triggered-actions/ Hope this helps. And maybe other forum members will have other ideas. Quote Link to comment Share on other sites More sharing options...
0 Iaron7 Posted April 19, 2021 Author Report Share Posted April 19, 2021 (edited) Thanks for the answer, it does look like using the Triggered Actions loop is the way to get the proper GCD. Im using a little quick and dirty solution for now. Since I wanted this to calculate on the fly, i had to use conditionals within the calcluated field. So if a ratio is 31/130, i divide the divisor by the dividend (130 / 31) and get 4.19 or 1 / 4.19. Now based on what the rounded tenths place of the quotient is, i either: .1 = round down .2 or .5 = multiply dividend and divisor by 5 or 2 respectfully. .3 = multiply by 3 and round up .4 = multiply by 2 and round up .6 = multiply by 2 and round down .7 = multiply by 3 and round down .8 = round up .9 = round up. This gets me to a reasonable ratio for the purposes of my report. Figured i'd share in case anyone else stumbled upon this and may find it useful for their case. Edited April 19, 2021 by Iaron7 misspellings Quote Link to comment Share on other sites More sharing options...
0 Kurumi Posted January 31, 2023 Report Share Posted January 31, 2023 Hello - if you want to use ROUNDDOWN and ROUNDUP like from Excel, you can use these formulas: Excel: Round to last nearest 5 = ROUNDDOWN(A2/5,0)*5 Round to last nearest 10 = ROUNDDOWN(A2/10,0)*10 Round to last nearest 50 = ROUNDDOWN(A2/50,0)*50 Round to last nearest 100 = ROUNDDOWN(A2/100,0)*100 Caspio: FLOOR([@field:Number]/50)*50 Excel: Round to next nearest 5 = ROUNDUP(A2/5,0)*5 Round to next nearest 10 = ROUNDUP(A2/10,0)*10 Round to next nearest 50 = ROUNDUP(A2/50,0)*50 Round to next nearest 100 = ROUNDUP(A2/100,0)*100 Caspio: CEILING([@field:Number]/5)*5 Quote Link to comment Share on other sites More sharing options...
0 NailDyanC Posted February 18, 2023 Report Share Posted February 18, 2023 Just want to add, you may check the function reference in Caspio's howto page for some possible formulas that you can use: https://howto.caspio.com/function-reference/ Quote Link to comment Share on other sites More sharing options...
Question
Iaron7
Any simple way to do this in a calculated field?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.