Jump to content

Search the Community

Showing results for tags 'sum'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Caspio Bridge
    • General Questions
    • Caspio JavaScript Solutions
    • Tables, Views and Relationships
    • Import/Export and DataHub
    • DataPages
    • Deployment
    • Security, Authentications, Roles, SAML
    • Styles and Localizations
    • Parameters
    • API and Integration
    • Calculations and aggregations
    • User JavaScript and CSS Discussions

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start




Website URL






Found 10 results

  1. I am trying to create a log sheet of sorts that shows the users transaction history. I have the table (as below) showing different transactions debit for income and credit for expenses but I want the balance column to show how the balance is increasing or decreasing as the transactions are coming in. ie User makes a deposit of 1000 and the balance also displays 1000, but next line he has an expense in the Credit column of 100 so balance should reflect 900. The table houses multiple users as seen above so that another users credit or debit doesn't influence other users balances.
  2. I am trying to create an app for horse show points tracking. The table Results has the fields Rider ID, Class ID, Class Type, and Points Rider1 | Class02 | ClassTypeA | 4 Rider1 | Class03 | ClassTypeA | 5 Rider1 | Class04 | ClassTypeA | 5 Rider1 | Class05 | ClassTypeA | 5 Rider1 | Class11 | ClassTypeA | 5 Rider1 | Class12 | ClassTypeA | 5 Rider1 | Class06 | ClassTypeA | 3 Rider1 | Class08 | ClassTypeA | 1 Rider1 | Class09 | ClassTypeA | 3 Rider1 | Class13 | ClassTypeB | 5 Rider1 | Class14 | ClassTypeB | 4 Rider1 | Class15 | ClassTypeB | 2 Rider1 | Class16 | ClassTypeB | 1 When we do our year end calculations, I need to find out the sum of each Rider's top six (highest Points value) Results for each Class Type (ie for Class Type A the bolded values). What would be ideal would be to have this eventually input into a new table with the following columns: Rider ID, Class Type A (sum of top 6), Class Type B, etc Rider1 | 29 | 12 | Etc I have been trying to use a Task to input the values I can use into a new table but I can't seem to get values that account for needing the top 6 for _each_ Rider and _each_ Class Type, unless I do one for each rider and class type combination, which would be waaaay too many tasks to do. (see image, nomination_id is Rider ID in my example). Is there some other way I should be going about this that I am missing?
  3. I am new so please excuse my SQL ignorance: My trigger is working, EXCEPT for the fact that it is NOT INCLUDING the most recently inserted value in the CommentHRS field in the sum (CA_TOTALhrs). Trying to be clear here: It's properly calculating the SUM on the insert event, but just not including the newly inserted value as part of the sum. (The actions with the red X work fine. No problems there.) Why would it not include the value that was just inserted in the SUM? Thanks. Mike
  4. I am trying to craft a trigger that will sum inserted rows (multiple rows) and put the total in another table. I cannot seem to find a way to select multiple rows from the #inserted table though. To explain further, I have three tables, Master, Details, Totals. When a new row is inserted into the master table an insert trigger fires on the master table and several detail rows are copied from a template table into the detail table, where each row contains a price and quantity. The price and quantity are multiplied to create a total for each row through a formula field in the details table. On the details table there is a triggered action that on insert, update or delete will sum the cost of the total formula column for all rows and put that total into a totals table. I have to sum the #insert and existing detail rows separately and add them together to get the total. This all seem to work well when inserting one row but when inserting multiple rows only the first row from the #inserted table is totaled. That makes sense because the trigger on the detail table doing the sum specifies Select top 1 from #inserted when summing. However, I need to sum multiple rows from #inserted and the trigger is not letting me remove the top 1 clause stating that it only expects one row from the select query. I have tried putting the select query for the inserted table within a sum block and alternatively putting a sum expression on the result of the select query. In both cases the trigger will not save stating that the select must specify top 1. I have attached some screen prints of what I am doing in the trigger and the issues with each scenario. TriggerValidationError.docx
  5. Hi, I'm new to using Caspio bridge. I am more accustomed to creating web forms directly using PHP and JQuery, but I need to make some updates to a Caspio form. I have a submission form that has 4 text fields. The first 3 fields will accept currency values. The last field sum sum the previous one in real time. For example, if in field 1 I enter value 25, then 25 should show in field 4 when event focus changes. If fields 1 and 2 have values 25 and 17, respectively, then when the event focus changes from field 2 the value in field 4 should be 42. I know how to d9 this using straight JavaScript or J-Query, but I am having trouble creating functions and adding triggers and events to the elements in my submission form. Any help would be greatly appreciated.
  6. Hi, I need help with calculating total sum based on values, entered in fields. I have 3 fields on the submission form, where users enter 3 values. I would like to calculate total in the forth field. Also, I want to show the value to the user. E.g when user enters value "5" in the first field, he will see "5" in the field Total then user enters "10" in the second field, he will see "15" in the field Total and finally user enters "7" in the third field, he will see "22" in the field Total And I wand to store value 22 in the table. Thanks!
  7. Good Morning, I'm need the sum of a 'paymentdue' field based on the date range (criteria) selected by the end-user. I'm currently using a sql select statement which is providing the grand total on the details page (formatted for use as the invoice). The sql statment is providing the grandtotal without any date criteria. I need the grand total to change (increase amount or lessen amount) based on the end-user's date range selections. Current Formula used in calculated field on details page: select sum(PaymentDue) from Test_Table where Name=target.[@field:Name] group by Name Tested the following statement which is not grabbing the date information selected from the caspio form thus returns the grand total w/o date criteria again: SELECT sum(PaymentDue) FROM Test_Table WHERE Start_Time >= [@field:Start_Time] AND End_Time <= [@field:End_Time] Is there anyway to have a details page pull the 'paymentdue' from the table based on the date range searched on the Caspio search form (I configured the details page to allow users to select data using the search form? I essentially need an aggregation function on the details page itself. I understand that this information cannot be saved...I'd just like for the grand total data to dynamically display on the invoice based on the end-user's selection. As always, I greatly appreciate any feedback that can be provided. Thanks!
  8. Hello, I'm using a tabular search and report for an invoicing application where I need to show aggregations of the RateAmount grouping by the RecIDL at the bottom of the RateAmount column. I want to pass the aggregated calculated field total to the invoice using an href link to my details page. Currently the link to the details page is showing an invoice for each RecIDL. I need the RecIDL to group on the tabular search and report with the aggregated total for each RecIDL. Here are the specifics: The Table name is 'Invoicing'. I have columns for 'RecIDL' and 'RateAmount'. For example: Table Name: Invoicing (Columns): RecIDL RateAmount (Vaules): L1 $100.00 L1 $100.00 L2 $150.00 L3 $175.00 I can aggregate totals and group by the RecIDL using the aggregate caspio field; however I need this information to pass to the actual invoice so a calculated field is required. I'd like to select the 'RecID column' and sum the 'RateAmount' and then group by the 'RecID.' I've tried the following select statements. SELECT RecIDL, SUM(IsNull(RateAmount,0)) FROM Invoicing_Loads GROUP BY RecIDL (*Expression Error Msg: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. ) SELECT RecIDL, SUM (RateAmount) FROM Invoicing GROUP BY RecIDL; (*Valid Formula per Caspio verify: When html page is opened "error in formula" message received; unable to view webpage) SELECT SUM(RateAmount) FROM Invoicing_Loads WHERE RecIDL = target.[@field:RecIDL] Group by RecIDL (*Statement is grouping the RateAmount for each RecIDL. The amount is appearing numerous times on the report; the total is correct.) This is what is showing: (The total should be $200.00 for L1) (Columns): RecIDL RateAmount (Vaules): L1 $200.00 L1 $200.00 L2 $150.00 L3 $175.00 This is what I need to see: Total Aggregations for each RecIDL; preferably at the bottom of each RecIDL group. (Columns): RecIDL RateAmount (Total L1): L1 $200.00 (Total L2) L2 $150.00 (Total L3) L3 $175.00 I'm not a strong sql user so I'm not certain what the "expression" error is speaking to. Based on the knowledge that I do have I believe it should work. I have searched the forums but could not locate any information specific to my need. I'd be grateful for any assistance provided. As always, Thank you! Bre
  9. This old post from Caspio should be updated with the following changes so that it works when Grouping is enabled: http://forums.caspio.com/index.php/topic/3171-js-calculate-column-sum-in-the-result-page/ Aggregation should be used instead, but if you want to SUM a Calculated Field which in turn is based on a sub-query, it will not be available for Aggregation. See the second paragraph here for details on this case http://howto.caspio.com/release-notes/caspio-bridge-9-0/9-0-known-issues/ I've highlighted the changes below </div> <script> function NumberFormatted(amount,decimal) { if(isNaN(amount)) i = 0.00; else { var v_number = parseFloat(amount); var v_minus = ''; if(v_number < 0) v_minus = '-'; v_number = Math.abs(v_number); v_number = Math.round(v_number*Math.pow(10,decimal)); v_number = v_number/Math.pow(10,decimal); v_numStr = new String(v_number); v_decStr = new String(Math.pow(10,decimal)); if(v_numStr.indexOf(".") < 0) v_numStr = v_numStr + "." + v_decStr.substr(1,v_decStr.length); else v_numStr = v_numStr + v_decStr.substr(1,v_decStr.length); return (v_minus + v_numStr.substr(0,v_numStr.indexOf(".") + decimal + 1)); } } function f_calTotal() { var v_totalRev = 0; var v_rev = 0; var cas_form = document.getElementById("cb_resultTotal"); if (cas_form.getElementsByTagName("table").length > 0) { //For counting all rows, so that we can use the count as the index for inserting a new row. var countRows = cas_form.getElementsByTagName("table")[2].getElementsByTagName("tr"); //For reading just the data rows, not the Grouping rows, to avoid null values. var cas_rows = cas_form.getElementsByTagName("table")[2].querySelectorAll('tr[data-cb-name=data]'); for(var rowIndex=1; rowIndex < cas_rows.length; rowIndex++) { //Narrows down to just data cells. var cells = cas_rows[rowIndex].querySelectorAll(".cbResultSetData"); /* 1 – change value inside brackets to choose column to calculate sum */ v_rev = cells[3].innerHTML; if ( v_rev != " " && !isNaN(v_rev.substr(1))) v_totalRev = v_totalRev + parseFloat(v_rev); } //New row will be based on count of all rows, not count of rows searched. var v_nrow = countRows.length; cas_form.getElementsByTagName("table")[2].insertRow(v_nrow); var o_lastRow = cas_form.getElementsByTagName("table")[2].rows[v_nrow]; o_lastRow.style.background = "#385C7E"; o_lastRow.insertCell(0); o_lastRow.insertCell(1); /* 2 – Display the “Total†label (2 lines below) */ var v_colText = o_lastRow.insertCell(2); v_colText.innerHTML = "<div style='padding:5px;color:#ffffff;font-size:14px;font-weight:bold;font-family:Arial'>Total</div>"; var v_colValue = o_lastRow.insertCell(3); /* 3 – Display the result of the calculation (2 lines below) */ v_colValue.innerHTML = "<div style='padding:5px;color:#ffffff;font-size:14px;font-weight:bold;;font-family:Arial'>$" + NumberFormatted(v_totalRev,2) + "</div>"; o_lastRow.insertCell(4); } } </script> <script> f_calTotal(); </script>
  10. I have a Submission form that has a Dropdown for "Product" and the next field uses a Cascading Dropdown for "Price". The following fields are "Additional Charges" and "Discounts". I want the next field to Total the previous three. I have placed the following code in the Footer of the Submission form: <SCRIPT LANGUAGE="JavaScript"> function summation() { var Cost = document.getElementById("InsertRecordPrice").value; var Additional_Charge = document.getElementById("InsertRecordAdditional").value; var Disc = document.getElementById("InsertRecordDiscount").value; var Total_Invoice = parseFloat(Cost) + parseFloat(Additional_Charge) + parseFloat(Disc); document.getElementById("InsertRecordTotal").value = Total_Invoice; } document.getElementById("caspioform").onsubmit=summation; </SCRIPT> When Price is a cascading dropdown, I do not get a value in the "Total" field. If I change price to a standard dropdown with custom values the above script works perfectly. In a perfect world, I really don't need a cascading dropdown for Price if I could figure another way to get the number into the field. The dropdowns are from a separate table called with the product name as column 1 and price as column 2. Any ideas on why this would be misbehaving? Thanks.
  • Create New...