ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: vijay@spinetechnologies on April 24, 2023, 05:58:19 pm
-
Hi Team,
How to achieve Row Wise and Column Wise Total of Hours and Minutes.
i.e if Minutes is greater than 59 then it should count as 1 hour and should be added in the hour part.
I have attached a ScreenShot for reference.
-
for row wise total, you can use column dependencies and for column wise total, summary can be used.
These 2 examples show both row and column wise calculations.
https://paramquery.com/pro/demos/summary
https://paramquery.com/pro/demos/summary_json
Following function can be used for addition of time values.
function addTime( times) {
const totalMinutes = times.reduce((total, time) => {
const [hours, minutes] = time.split(':').map(Number);
return total + (hours * 60) + minutes;
}, 0);
const totalHours = Math.floor(totalMinutes / 60);
const totalMinutesMod = totalMinutes % 60;
const resultHours = String(totalHours % 24).padStart(2, '0');
const resultMinutes = String(totalMinutesMod).padStart(2, '0');
return resultHours + ":" + resultMinutes;
}
-
Hi Team,
Thanks for the Solution.
We have another case in which we are using Pivot Feature. In Pivot the Last Column is auto-generated, So in this scenario can we apply the above addTime function?
We have attached a screenshot for your reference.
-
Yes, of course. make the necessary changes in function since in your case "." is the separator instead of ":" between hour and minute.