web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can't create flat coll...
Power Apps
Answered

Can't create flat collection despite all dataverse schema is the same

(2) ShareShare
ReportReport
Posted on by 15

Summary:

PowerApps Canvas: 'Invalid argument type' on Collect from identical Dataverse Filters—only when Trains section matches others; workaround nests tables.

Problem:

In the Participant screen (somewhere in the middle of the wizard-like app) I want to build and maintain a collection of services (colServiceData) for the selected participant in order to dynamically show cards with some basic data and set flagServiceSelected when navigate to the service screen for editing/viewing or want to delete the selected service.

When I start to collect (colServiceData) from services one-after-another, it works fine with the below code. HOWEVER all Collect calls in the If block fail with 'Invalid argument type' errors—but only when 4.f uses the exact ForAll(Collect()) pattern matching 4a–4e/4g–4h.

Strangely enough the error disappears if I delete the snippet in 4.f section or I change it like it is now (to collect the table returned by ForAll), which is utterly different how I collect from the other tables and is not what I intend, it works. I want to have a flattened table with each row a record not a table. AIs suggested the current ForAll-inside-Collect creates nested tables (ForAll returns table, causing potential data loss on flatten)

What especially strange is that only happens when the 4.f section is the same as the others, as it should be, within the If() block. When I delete or change that part, it works. However that means the colServiceData will have no coherent structure/schema.

Context:

I have 8 service tables in dataverse, each has a lookup field to Participation table which in turn has lookup fields to Traveler and Travel tables. The architecture is to connect the services to travelers (*-1) and travelers to travels (*-1).

The dataverse tables are the very same when it comes to GUID and lookup, I double checked them two times. Differences are only in other columns.

AIs keep telling it is likely schema inference failure, but that seems impossible.

(one last note, my original code contains many hungarian parts, as the dataverse table and column names are in hungarian, and I changed those here to english, but that's why there are some in quotes)

Here is the code.

 
// Clear and prepar necessary collections
ClearCollect(colReszvetelData, Blank());
Clear(colServiceData);

// Request data from Participants and Travelers datasource, merge, and store it to colParticipantData (only if Edit or View)
If(
    varParticipantMode <> "New",
    ClearCollect(
        colParticipantData,
        AddColumns(
            Filter(
                Participants,
                // Filter: only Participants belonging to the current Travel
                Travel.TravelId = varUtazas.TravelId
            ),
            // Merged Traveler fields — LookUp into Traveler via the lookup on each row
            'Traveler Name',
            LookUp(Travelers, Traveler = ThisRecord.Traveler, 'Traveler name'),
            'Traveler Email',
            LookUp(Travelers, Traveler = ThisRecord.Traveler, 'Traveler email address')
        )
    )
);

//HERE is the probelm with 4f. ONLY. If it is the same as the others, the whole block breaks, if it is changed to Collect first then ForAll there's no error. WTF?
/* Request only those data to be shown from all Services datasource that is linked to the current Participant 
and store colServiceData (only if Edit or View). Service records are only collected if their parent Participant belongs to the current Travel.
By chaining the 8 Collects, they all append to the same colServiceData.
*/
If(
    varReszvetelMode <> "New",
    /* --- 4a. Planes --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    Planes,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "Plane",
                ServiceRecordId,  ThisRecord.PlaneId,
                DisplayLabel,     ThisRecord.Departure &
                                    " → " & 
                                    ThisRecord.Destination & 
                                    ", " & 
                                    Text(ThisRecord.'SegmentType') & 
                                    " " & 
                                    Text(ThisRecord.'SegmentDirection')
            )
        )
    );

    /* --- 4b. Hotel --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
        
            AddColumns(
                Filter(
                    Hotels,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "Hotel",
                ServiceRecordId,  ThisRecord.HotelId,
                DisplayLabel,     ThisRecord.HotelName &
                                    ", " &
                                    Text(ThisRecord.Checkin, "MM.dd") & 
                                    " - " &
                                    Text(ThisRecord.Checkout, "MM.dd")
            )
        )
    );

    /* --- 4c. CarRent --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    CarRents,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "CarRent",
                ServiceRecordId,  ThisRecord.CarRentId,
                DisplayLabel,     ThisRecord.PickupPlace &
                                    ", "  & 
                                    Text(ThisRecord.PickupDate', "MM.dd")
            )
        )
    );

    /* --- 4d. Registration --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    Registrations,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "Registration",
                ServiceRecordId,  ThisRecord.RegistrationId,
                DisplayLabel,     ThisRecord.Title &
                                    " "  & 
                                  ThisRecord.Amount
            )
        )
    );

    /* --- 4e. Transfer --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    Transfers,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType',      "Transfer",
                ServiceRecordId,  ThisRecord.TransferId,
                DisplayLabel,     Text(ThisRecord.'SegmentType') & 
                                    " " & 
                                    Text(ThisRecord.'SegmenDirection') &
                                    ", " & 
                                    Text(ThisRecord.'TransferType')
            )
        )
    );

    /* --- 4f. Train --- */
    Collect(
        colServiceData,
        ForAll(
            colParticipantData As CurrentParticipant,
            AddColumns(
                Filter(
                    Trains,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,    "Train",
                ServiceRecordId, ThisRecord.TrainId,
                DisplayLabel,    Text(ThisRecord.DepartDate, "MM.dd")
            )
        )
    );
    

    /* --- 4g. Visa --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    Visas,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "Visas",
                ServiceRecordId,  ThisRecord.VisaId,
                DisplayLabel,     ThisRecord.Country & 
                                    ", " & 
                                    Text(ThisRecord.DateIn, "MM.dd") &
                                    " - " & 
                                    Text(ThisRecord.DateOut, "MM.dd")
            )
        )
    );

    /* --- 4h. Insurance --- */
    ForAll(
        colParticipantData As CurrentParticipant,
        Collect(
            colServiceData,
            AddColumns(
                Filter(
                    Insurances,
                    Participant.ParticipantId = CurrentParticipant.ParticipantId
                ),
                participantId,    CurrentParticipant.ParticipantId,
                ServiceType,      "Insurance",
                ServiceRecordId,  ThisRecord.InsuranceId,
                DisplayLabel,     ThisRecord.Country & 
                                    ", " & 
                                    Text(ThisRecord.'DateOut', "MM.dd") &
                                    " - " & 
                                    Text(ThisRecord.'DateIn', "MM.dd")
            )
        )
    )

   
);
 
I have the same question (0)
  • Suggested answer
    Soufyane Profile Picture
    69 on at

    Schema is getting inferred from the first Collect call, and by the time it hits 4f it conflicts that's why the whole block breaks.

    Predefine the schema before your If block:

    ClearCollect(

    colServiceData,

    {

    participantId: "",

    ServiceType: "",

    ServiceRecordId: "",

    DisplayLabel: ""

    }

    );

    Clear(colServiceData);

    Then use the same ForAll(Collect()) pattern on 4f like all the others. That's it.

    If this helps, please mark your question as answered.

     
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    The “Invalid argument type” error in Microsoft Power Apps is caused by a schema mismatch in Collect()—not by your logic.
     
    In my analysis, cause of this issue:
    • All Collect() operations must have:
      • Same column names
      • Same data types
    • The 4.f (Trains) section likely has a mismatch (e.g., different ID type, null values, or typo)
    • Even a small difference (like ' in column name or GUID vs text) breaks the entire block
  • Suggested answer
    Assisted by AI
    BCBuizer Profile Picture
    22,833 Super User 2026 Season 1 on at
     
    A slightly different approach that should give the desired result is by creating a collection of nested tables for all services and then flattening that with an Ungroup() function:
     
    ClearCollect(
        colServiceData,
        Ungroup(
            Table(
                {
                    ServiceTable: AddColumns(
                        Filter(Planes, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Plane",
                        ServiceRecordId, PlaneId,
                        DisplayLabel, Departure & " → " & Destination & ", " &
                                      Text('SegmentType') & " " & Text('SegmentDirection')
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Hotels, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Hotel",
                        ServiceRecordId, HotelId,
                        DisplayLabel, HotelName & ", " &
                                      Text(Checkin, "MM.dd") & " - " & Text(Checkout, "MM.dd")
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(CarRents, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "CarRent",
                        ServiceRecordId, CarRentId,
                        DisplayLabel, PickupPlace & ", " & Text(PickupDate, "MM.dd")
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Registrations, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Registration",
                        ServiceRecordId, RegistrationId,
                        DisplayLabel, Title & " " & Amount
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Transfers, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Transfer",
                        ServiceRecordId, TransferId,
                        DisplayLabel, Text('SegmentType') & " " & Text('SegmentDirection') & ", " & Text('TransferType')
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Trains, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Train",
                        ServiceRecordId, TrainId,
                        DisplayLabel, Text(DepartDate, "MM.dd")
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Visas, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Visa",
                        ServiceRecordId, VisaId,
                        DisplayLabel, Country & ", " &
                                      Text(DateIn, "MM.dd") & " - " & Text(DateOut, "MM.dd")
                    )
                },
                {
                    ServiceTable: AddColumns(
                        Filter(Insurances, Participant.ParticipantId in colParticipantData.ParticipantId),
                        participantId, Participant.ParticipantId,
                        ServiceType, "Insurance",
                        ServiceRecordId, InsuranceId,
                        DisplayLabel, Country & ", " &
                                      Text(DateOut, "MM.dd") & " - " & Text(DateIn, "MM.dd")
                    )
                }
            ),
            "ServiceTable"
        )
    );
     
    Besides this being more manageable, it should perform better as well since all the ForAll loops were removed. 
     
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer âś….
  • Verified answer
    KT-04020709-0 Profile Picture
    15 on at
    Thank you all for the answers, all are great approach.
    I specifically want to avoid working with nested tables, and don't have any experience with Ungroup(), so I'd avoid that. But that is something I'll explore in the future.
    Prdefining the schem was something I tried many times, still breaking the app, as you can see the Collect() schema is the very same at all section.
     
    Turned out the problem was kind-of dataverse schema mismatch. Precisely both Planes (4.a) and Trains (4.f) tables in dataverse had a choice column with the very same name but different optionset. That's all. I deleted the column from one table, then re-created it with different name and it all works.
     
    Anyway thank you for your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard