1

I am creating a PowerApp that uses two SP lists:

  1. PowerAppCalendar1 (An actual calendar in SP). One added field is Capacity
  2. TrainingAttendees - the folks who want to join a class use this list

This second list includes a lookup field from the PowerAppCalendar.Title field into a field called "ClassfromCalendar:Class", which also brings in ":ID", ":StartTime", etc.

The most important field on this list is "Participantcount". For each row that's added, a class "requestor" can say how many people they need to attend that class.

What I need to do is group by the Class ID field, and sum the participantcount field for each class ID. My hang up is Class ID doesn't come in as text, it comes in as a record into the collection, so I can't group by it. My less-than-elegant workaround was to create a Power Automate that writes the ClassfromCalendar:ID lookup value to a ClassID text field I also added to the TrainingAttendee list. I'm worried I can't rely on PowerAutomate to NEVER fail, so I'd really prefer all this functionality remain in the PowerApp.

Here is the code that worked with the ClassID text field:


      ClearCollect(
           TotalofParticipantsPerClass,
           DropColumns(
               AddColumns(
                   GroupBy(AttendeeList, "ClassID", "GroupedItems"),
               "ParticipantTotalPerClass",Sum(GroupedItems, ParticipantCount)
               ),
           "GroupedItems"
           ) );

So what I really am trying to do is replace "ClassID" in the code above with the ClassfromCalendar:ID field that comes in, instead. The error I get is that a different type is expected, which I understand, because it comes in as a a record/table, not text.

Any help you can provide would be appreciated. I am a good problem solver (hence my Power Automate workaround!), but I'm TERRIBLE with PowerApps syntax!

Thanks!

1 Answer 1

1

To share with others who might be experiencing this same issue, I found a resolution.

The code that worked can be found below:

ClearCollect(
    TotalofParticipantsPerClass,
    AddColumns(
        GroupBy(
            ShowColumns(
                AddColumns(
                    TrainingAttendees,
                    "ClassIDNumber",
                    'ClassFromCalendar:ID'.Value
                ),
                "ClassIDNumber",
                "ParticipantCount"
            ),
            "ClassIDNumber",
            "GroupedItems"
        ),
        "ParticipantTotalPerClass",
        Sum(
            GroupedItems,
            ParticipantCount
        )
    )
);

Thanks to all those who at least read it and gave it some thought.

Hopefully my few days of head-banging will help others!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.