-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
I am attempting to display a labor report which displays employee shift hours. Each row has a column for employee that has the total number of shift seconds worked.
Viewers of this report would prefer to see the data in a more friendly, readable way like 5h 30m worked for a shift as opposed to 19,800 seconds or 5.5 hours.
The labor report has a few grouped columns and the shift time is summed correctly when dealing with a purely numeric type as shown here.
Screenshot 2025年03月27日 at 9 55 58 AMThe Shift Hours is a computed column with the formula ("Shift Seconds" / 3600) which works fine as sum and adds up just fine.
The problem I am having is when I try to put in a formula to add a new computed column that converts it to the more human readable format (which ends up converting it to a string). Once converted to a string it can no longer be used as a sum.
Here when I attempt to create a computed column that represents the number of hours worked as, e.g. 6h as it is converted to a string representation, it can no longer be used as a sum, and grouped rows will no longer sum. It has to be specified as unique
I was hoping to work around this by making a hidden computed columns that just had the truncated integer representation for hours and minutes, and then use another computed column that uses those int sum columns to display them as a string, but it seems that a computed column cannot be referenced in ExprTk by another computed column.
Is there a possible workaround to achieve my ultimate goal which is to be able to represent the integer sum Shift Seconds in human readable string format 6h 30m but maintain the column sum for grouped row summaries?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
This is a formatting problem, other grids like agGrid solve this by using valueFormatters.
I think perspective can adopt the same idea by supporting expressions over base columns purely for formatting without affecting the original value of the base column.
This would allow for fully custom formatting while keeping the UX simple.
Beta Was this translation helpful? Give feedback.