No problem! To calculate the total time in minutes for every MonthYear combination that has tasks, you can use a combination of GroupBy, AddColumns, and Sum functions in PowerApps. Here's how you can achieve that:
Step 1: Create a new label or text input in your PowerApps app to allow the user to input the desired year.
Step 2: Add a button that the user will click to trigger the calculation.
Step 3: Use the following formula for the button's OnSelect property:
ClearCollect(
FilteredTasks,
Filter(
YourCollectionName,
Year(DueDateColumn) = Value(YearInput.Text)
)
);
ClearCollect(
GroupedTasks,
AddColumns(
GroupBy(FilteredTasks, "MonthYear", "Month(DueDateColumn) & \"/\" & Year(DueDateColumn)"),
"TotalInMin",
Sum(Results, TimeInMinutesColumn)
)
)
In this code:
YourCollectionName should be replaced with the actual name of your collection that contains task information.
DueDateColumn should be replaced with the actual column name in your collection that contains the due date for each task.
TimeInMinutesColumn should be replaced with the actual column name in your collection that contains the time in minutes for each task.
YearInput refers to the input field where the user can specify the desired year.
FilteredTasks is a temporary collection used to store only the tasks that belong to the selected year.
GroupedTasks is another temporary collection used to store the grouped tasks by MonthYear along with the calculated total time in minutes for each group.
Step 4: Finally, you can use a gallery or a data table to display the contents of the GroupedTasks collection, showing the MonthYear and the corresponding TotalInMin for each month-year combination that has tasks.
With this setup, when the user enters a year and clicks the button, PowerApps will filter the tasks for the given year, group them by MonthYear, and calculate the total time in minutes for each MonthYear combination that has tasks. The resulting data will be stored in the GroupedTasks collection, which you can then use to display the information in your app.