Just a small complement, to the ToHours() suggestion by @Christiaan_Huizer
…
You could get your total of hours for today in a canvas formula using something like this :
Format(
"{1} {2}",
Durations.Filter(Date = Today()).Duration.Sum().ToHours(),
If(Durations.Filter(Date = Today()).Duration.Sum().ToHours() <= 1,"hour","hours")
)
Format() creates a text value based on a template where you can use placeholders. Here, the template is "{1} {2}".
The 1st placeholder ({1}) is for total of hours for today …
Durations.Filter(Date = Today()).Duration.Sum().ToHours()
… And what it does is it take the table called Durations (see sample below
) filter the dates in the Date column and keep only the ones where Date = Today(), then for those rows it goes and look for the corresponding values in Duration… Sum those Duration and converts the result as hours with ToHours
.
The 2nd placeholder ({2}) is completely optional and could be replaced by “hours” in the template (
- i.e.: using "{1} hours" as a template in Format() instead of "{1} {2}"), as it is just there to write “hour” in its singular form or plural one
.
For the total hours for this week, it’s kind of the same formula
…
Format(
"{1} {2}",
Durations.Filter(Week = Today().WeekNumber()).Duration.Sum().ToHours(),
If(Durations.Filter(Week = Today().WeekNumber()).Duration.Sum().ToHours() <= 1,"hour","hours")
)
… But, for the 1st placeholder ({1}), instead of filtering the Durations table by Date, it filters the column called Week and keep only the rows where Week = Today().WeekNumber()
.
Once again, the 2nd placeholder could be replaced by “hours” in the Template of the Format()
.
This would be feasible with Concatenate() too
.