Objective: Get the count of rows and Sum of Net Payables per month.
Sample Data:
Net Payables Date Created
14,523.00 1-Dec-24
34,253.00 2-Dec-24
23,562.00 1-Jan-25
135,664.00 3-Jan-25
1,234,566.00 5-Jan-25
Code so far:
ClearCollect(TempTransCol,'Temp Transaction');
ClearCollect(
ColGroupedData,
AddColumns(
GroupBy(
TempTransCol,
Text('Date Created', "mm-yyyy"),
GroupItem
),
TotalCount,
CountRows(GroupItem),
SumNet,
Sum(GroupItem,'Net Payable')
)
);
Error Received: Name isn't valid. 'Date Created' isn't recognized.
In the GroupBy function you cannot use an arbitrary expression (such as Text('Date Created', "mm-yyyy")
) in the columns to be grouped. You can fix this by using the AddColumns function to create a new column with that value, like the expression below:
ClearCollect(
ColGroupedData,
AddColumns(
GroupBy(
AddColumns(TempTransCol, 'DateCreatedMonthYear', Text('Date Created', "mm-yyyy")),
DateCreatedMonthYear,
GroupItem
),
TotalCount,
CountRows(GroupItem),
SumNet,
Sum(GroupItem,'Net Payable')
)
)
That should give you the grouped collection you need.