Page 1 of 1
How to apply a data format in the calculated field
Posted: 2021-01-11 16:28
by afayez
Dear,
Good day,
I have a calculated field (Quantity * Price). i tried to make a numbers format 12,345.67 bit it gave an erroe message:
Error checking:
Warning: Skipping calculations for field 'qtn.total': This field can't be a calculated field.
Reason: Fields that have a data format specified can't be calculculated fields (you can apply a data format in the calculation instead)
Finished error checking.
PHP application generation process cancelled by user.
Support please how can apply a data format in the calculation instead.
Re: How to apply a data format in the calculated field
Posted: 2021-01-11 16:41
by pbottcher
Hi,
try
FORMAT(FIELDNAME or CALCULATION,2,'YOURLANGUAGENEED')
for what you show it should be standard and you could use
FORMAT(FIELDNAME or CALCULATION,2)
Re: How to apply a data format in the calculated field
Posted: 2021-01-12 03:45
by afayez
Thanks
i tried to put {FORMAT( `all_invoices` ,2)} at the end of the formula but it didn't work, can you support
SELECT
SUM(`invoices`.`sum`)
FROM
`projects` LEFT JOIN
`invoices` ON `projects`.`id` = `invoices`.`project_id`
WHERE
`projects`.`id` = '7'
FORMAT( `all_invoices` ,2)
Re: How to apply a data format in the calculated field
Posted: 2021-01-12 07:01
by pbottcher
Hi,
can you try
Code: Select all
SELECT
FORMAT(SUM(`invoices`.`sum`),2)
FROM
`projects` LEFT JOIN
`invoices` ON `projects`.`id` = `invoices`.`project_id`
WHERE
`projects`.`id` = '7'
Re: How to apply a data format in the calculated field
Posted: 2021-01-12 07:09
by jsetzer
Additional notes:
https://www.w3resource.com/mysql/mathem ... unded%20up.
Please note that sum(...) returns a numeric value but format(sum(...), 2) returns a string. If you are facing problems, check the data type of that field.
Also, when using the calculated field for subsequent calculations, remember that this is a string now and not a number. Especially when format returns strings containing comma "," or point "." due to locale settings this could lead to follow up miscalculations.
Re: How to apply a data format in the calculated field
Posted: 2021-01-12 07:30
by afayez
Thanks alot
It worked very well.
but the couloumn sum is not working well. as in the attached photo.
Re: How to apply a data format in the calculated field
Posted: 2025-03-30 16:36
by lakmal.c
Please i need to change currency symbol , let me know how to change the currency symbol
Re: How to apply a data format in the calculated field
Posted: 2025-03-31 06:42
by pbottcher
Hi,
can you be a bit more specific. What do you have, what do you try to achieve, what have you tried so far? With just the sentence you wrote it is unclear how to support you.