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
Suggested Answer

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

(2) ShareShare
ReportReport
Posted on by 5

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
    14 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
    853 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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard