Calculating total of column

@lubos
I am trying to calculate the total of a column but it takes the element as text and not as number. Inside the loop I have written this.
{% assign myVar = cell.text | convert: “number” | plus: myVar %}

Please do not divert topics with unrelated questions. Your post has been moved to a new topic.

This is not a coding forum. Users are responsible for their own custom themes.

@lubos @Tut
Yeah so tell me how to access it as a number. I understand this is not a coding forum but the code which works on liquid IDEs doesn’t work in the custom themes. If it wouldnt have worked anywhere else then it’s my issue but if it’s not working only here,then you have to provide me with an alternative. Otherwise tell me table name in which the details of specific invoice are stored. Or give me alt approach to access the elements like using cell.text

Is there any other way in which the cell elements can be accessed apart from using cell.text or convert them to a number?

I will expose cell.value variable which would contain number. I already made it for custom fields but I think it should be done for cells as well.

What exactly are you doing? Using custom fields on line items and want to show total?

Hi @lubos thanks for providing an alternative.
Yeah I am calculating the total of a column by accessing its HTML DOM in liquid and performing a sum on that to calculate the total of a column.

It can be thought as calculating the total amount or total quantity in a sales invoice. And then show the total.

Added to the latest version (18.9.26).

Instead of “convert” filter (which didn’t work), use value property of cell instead.

For example:

{% assign myVar = cell.value | plus: myVar %}

1 Like

Hi
My name is Mohyadin Gure. I would like to contact to sales department.

@Robb_Stark winter is coming and we need help to calculate sum on qty colum.
Can you help the seven kingdoms by sharing your custom theme? I have not good knowledge in liquid but i can modify a theme via trial and error if i have one?
Can you help please?

2 Likes

Do not include personal information in your posts. Your email address has been removed. See https://forum.manager.io/faq.

There is no sales department to contact. Post your question on the forum.

@lubos if we calculate “Total Qty” using this method, will we be able to access “Total Qty” in custom reports after selecting Sales Invocie?
and can you please share all the lines that we need to place in template to calculate “Total Qty”

No, @Asif_Hussain, you will not. The technique discussed in this topic applies to custom themes, which display information. Custom reports access the database directly. The total quantity calculated according to the method above is not stored there.

Why calculation is not allowed in custom fields? this will make our life very easy, any plan of allowing it in future?

Calculations are allowed using custom fields. But they require a custom theme. See https://www.manager.io/guides/17115.

The reason you cannot perform calculations in custom fields without a custom theme is that the program has no coding telling it what to do with the data. And custom fields can be of many types, only one of which is a number.

yes but by using that method, you cant have that custom field in custom report, can we assign the result of that calculation to a custom field e.g field 3 = field 1 + field 2 ?
If calculations are allowed when custom field is of type “Number” that will make be very useful, people can automate calculations instead of doing it manually on each invoice

You cannot do what you you describe except with a custom theme. The result will be available only for display by that theme for that transaction.

You need to understand that Manager’s custom fields are only informational. The program makes no use of their content for accounting purposes, because they are not known in advance. It stores the information you enter for display, but does not use it for any of its own calculations. That would lead to big problems, since users do not know all the things the program does.