ttanemori Posted March 15, 2020 Report Share Posted March 15, 2020 I have a DataPage that shows Total and Due by Group. I used two aggregations, one is SUM for total and another one is SUM-2100 for due. Those values are fine in Group, but Caspio tries to calculate from entire values. I assume that "-900" is coming from 2100-(400+800). What is the best way to show "-3000" in TOATAL DUE? (COUNT([@field:Applicants_Email])*2100-SUM) did not work because COUNT increase a number by one. I am fine to hide "TOTAL DUE" if there is no good way. But, I cannot find a way to hide it. Any idea? Thank you very much. Quote Link to comment Share on other sites More sharing options...
0 CoopperBackpack Posted May 25, 2020 Report Share Posted May 25, 2020 Hello @ttanemori, Since the formula in the Aggregations has the same logic for Totals and groups, please try this JavaScript code. This code replaces the value in the Total Due with the sum of values that you receive in the groups (in your example it summarizes -1700 and -1300). <script type="text/javascript"> document.addEventListener('DataPageReady', sumGroups); function sumGroups() { const totals = []; document.querySelectorAll("td[class*='cbResultSetGroup1LabelCellNumberDate']").forEach(elem => { totals.push(elem.innerText); }); const result = totals.reduce( (accumulator, currentValue) => parseFloat(accumulator) + parseFloat(currentValue) ); document.querySelector('tr[data-cb-aggregation="Aggregate1"] > .cbResultSetTotalsData').innerText = result; document.removeEventListener('DataPageReady', sumGroups); }; </script> Replace Aggregate1 with the Aggregate2, etc. depending on the number of your Aggregate field. Add this code to the Header section on the "Configure Results Page Fields" screen of your DataPage. Do not forget to disable HTML editor before pasting the code. Quote Link to comment Share on other sites More sharing options...
Question
ttanemori
I have a DataPage that shows Total and Due by Group.
I used two aggregations, one is SUM for total and another one is SUM-2100 for due.
Those values are fine in Group, but Caspio tries to calculate from entire values.
I assume that "-900" is coming from 2100-(400+800). What is the best way to show "-3000" in TOATAL DUE?
(COUNT([@field:Applicants_Email])*2100-SUM) did not work because COUNT increase a number by one.
I am fine to hide "TOTAL DUE" if there is no good way. But, I cannot find a way to hide it. Any idea?
Thank you very much.
Link to comment
Share on other sites
1 answer to this question
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.