benz84 Posted May 7, 2010 Report Share Posted May 7, 2010 Hello, I want to display the sum of all numbers in a column on the results page. The numbers are currency. I prefer for the sum to be showed at the top of the page or above the respective column and denote that it is the sum of that column. Any code as to how to achieve this? Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted May 11, 2010 Report Share Posted May 11, 2010 Hello, You can take a look at the sample Java Scripts at viewforum.php?f=14. There is one "JS: Calculate column sum in the result page" which seems to be what you are asking for. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
jsinger Posted May 17, 2010 Report Share Posted May 17, 2010 I've tried to use that sample script. I set up a table to follow the requirements to be used "as is" and it does not work. That script is faulty. Quote Link to comment Share on other sites More sharing options...
paulbalas Posted May 17, 2010 Report Share Posted May 17, 2010 I have the same problem. The script works, but creates a total of '0'. Also, I'd like to know how to best create a 'group by' sum of detail data? Can we create our own views that have group by in the sql? Quote Link to comment Share on other sites More sharing options...
dragonfly Posted May 17, 2010 Report Share Posted May 17, 2010 I do not think the script is faulty, it works for my app. It just needs to be customized according to your results table and column indexes. For example if you have a download option enabled on your results page you need to reference the results table with index 2 because it will be the third table in the page. I would suggest if you use Firefox browser and add Firebug add-on which shows you the errors on the page. This way you can better address the issue as it spots the lines you have errors on your code. After all, even if you missed to change or typed wrongly of a single field name, it won't work. Quote Link to comment Share on other sites More sharing options...
hbasluc Posted May 18, 2010 Report Share Posted May 18, 2010 If you have your columns format to show as currency, the reason the script is Displaying a total of "0" is that each time the code comes to an element in the designated column, it's not accounting for the currency symbol (e.g. - "$", "€") and punctuations (e.g. - "," in the thousands, millions... place) and is returning a value of "0". Remedy to remove the symbols for NaN ("Not a Number") Clarification: replace - " v_rev = cells[COLUMNNUMBER].innerHTML; if ( v_rev != " " && !isNaN(v_rev.substr(1))) " with - " v_rev = cells[COLUMNNUMBER].innerHTML; v_rev = v_rev.replace(/,/gi, '') v_rev = v_rev.replace(/$/gi, '') v_rev = v_rev.replace(/€/gi, '') if ( v_rev != " " && !isNaN(v_rev)) " Quote Link to comment Share on other sites More sharing options...
hbasluc Posted May 18, 2010 Report Share Posted May 18, 2010 One last modification: Replace: " v_rev = v_rev.replace(/,/gi, '') v_rev = v_rev.replace(/$/gi, '') v_rev = v_rev.replace(/€/gi, '') " With: " v_rev = v_rev.replace(",", "") v_rev = v_rev.replace("$", "") v_rev = v_rev.replace("€", "") " Quote Link to comment Share on other sites More sharing options...
danieljones2006 Posted June 25, 2010 Report Share Posted June 25, 2010 The problem is it still creates a total of '0', so anyone please help out. Quote Link to comment Share on other sites More sharing options...
ChrisJ Posted November 3, 2010 Report Share Posted November 3, 2010 Think the initial issue is realized in 6.9 release. Now you can add "Aggregation" (SUM) and show it above table, below table, as well as both above and below. http://howto.caspio.com/release-notes/w ... e-6-9.html to paulbalas> Also grouping is enabled and you can sum values in the 1st group. Quote Link to comment Share on other sites More sharing options...
ChrisJ Posted November 3, 2010 Report Share Posted November 3, 2010 BTW. Result total can be formatted to be displayed as Currency (EUR, USD, etc. depending on localization settings). Quote Link to comment Share on other sites More sharing options...
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.