Numeric Format Error Message

Wappler Version : 6 with beta channel
Operating System : W11
Server Model: NodeJS

Expected behavior

Please post your full expression here.

Hey @ben,

Maybe you need to add the toNumber() on the sum (before the formatCurrency)?
Can you hardcode it?

Your expression has too many left parentheses in the beginning

1 Like

Sorry, wrong data formats panel. This is the relevant one:

Full dmx-text:
dmx-text="'Total Amount:'+(dsCart.data.sum('price' * 'quantity')).toNumber().formatCurrency('$','.',',',2)"

Or:
Total Amount: {{(dsCart.data.sum('price' * 'quantity')).toNumber().formatCurrency('$','.',',',2)}}

George was right…
there was a second starting parenthesis added there from the wappler binding ui…

That is what Wappler has done. When you see my handwritten code, you will see that all is well.

1 Like

exactly

1 Like

Shouldn’t this be actioned? Unless you do not mind me showing the workaround in my tutorial video.

I was able to replicate this, it seems the issue comes when you want to do maths price * quantity inside the sum property field.
In order to avoid such complex expressions in your code you can use the generated columns option for the data store. You can create a column called total that gets the price * quantity for each line:

In your code this looks like:

<dmx-datastore id="datastore1" dmx-bind:columns="{total:`price*quantity`}"></dmx-datastore>

And then you can simply sum all the total fields:

@Teodor, I have tried your solution without success.

This is what I have at the moment; notice the shopping-cart button.

As soon as I add Generated Columns, the button disappears and the Add to Cart button malfunctions.

Removing the Generated Columns allows the app to function as intended. The only problem is the formating of:

<td colspan="5" class="text-end fw-bold" dmx-text="'Total Amount '+dsCart.data.sum(`(price * quantity)`).formatCurrency('$', '.', ',', 2)">

Without the currency, it is not a problem; adding the currency shows the error message shown in a previous reply.