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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem creating a nes...
Power Apps
Answered

Problem creating a nested collection

(0) ShareShare
ReportReport
Posted on by 331
Hello all,
 
I need to create a nested collection of teachers' schedules and display them in a nested gallery.
I've been trying to create my collection for over 2 days now, without success:
The idea is as follows:
I have a sharepoint list with a ProfName, DayNumber, PeriodNumber and Class column.
In my application I have a choice list to search for a teacher. When my choice list is modified, I trigger the event and fill my Occupation collection as follows:  
 Create a collection of 5x13 elements (5 days and for each 13 teaching periods).
For each item in my suite, I search my sharepoint list for the day number (Value1 in my list), period number and teacher name.
Here's where I'm at, without success:
 
ClearCollect(
    TimeTable;
    ForAll(
        [1; 2; 3; 4; 5]; // Boucle sur les jours de la semaine (1 = Lundi; 5 = Vendredi)
        With(
                DayNumber: Value; // Capture la valeur du jour dans une variable de contexte
                DayName: Switch(
                    Value;
                    1; "Lundi";
                    2; "Mardi";
                    3; "Mercredi";
                    4; "Jeudi";
                    5; "Vendredi"
                )
            };
            {
                Day: DayNumber;
                JourNom: DayName;
                ListPeriodes: ForAll(
                    Sequence(13); // Boucle sur les périodes (de 1 à 13)
                    With(
                        {
                            ClasseValue: LookUp(
                                SharepointList;
                                DayNumber = Day && PeriodNumber = Value; // Utilisation de JourValeur et PeriodeValeur
                                Class
                            )
                        };
                        {
                            Periode: Value;
                            Matiere: Blank();
                            Classe: If(IsBlank(ClasseValue); Blank(); ClasseValue);
                            Remplacant: Blank();
                            Annotation: Blank()
                        }
                    )
                )
            }
        )
    )
)
 
The first error message says : DayNumber is invalid because unknown ..

Here's the place where my collection should be used :
 
So any idea is very welcomed :)
I have the same question (0)
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    hey
     
     
    can u try this approach:
    ClearCollect(
        TimeTable,
        ForAll(
            [1, 2, 3, 4, 5],
            With(
                {
                    DayNumber: Value,
                    DayName: Switch(
                        Value,
                        1, "Lundi",
                        2, "Mardi",
                        3, "Mercredi",
                        4, "Jeudi",
                        5, "Vendredi"
                    ),
                    Periods: ForAll(
                        Sequence(13, 1, 1),
                        With(
                            {
                                ClasseValue: LookUp(
                                    SharePointList,
                                    ProfName = DropdownTeacher.Selected.Value &&
                                    DayNumber = DayNumber &&
                                    PeriodNumber = Value,
                                    Class
                                )
                            },
                            {
                                Periode: Value,
                                Classe: If(IsBlank(ClasseValue), Blank(), ClasseValue),
                                Matiere: Blank(),
                                Remplacant: Blank(),
                                Annotation: Blank()
                            }
                        )
                    )
                },
                {
                    Day: DayNumber,
                    JourNom: DayName,
                    ListPeriodes: Periods
                }
            )
        )
    );
    
    if it worked please mark as verified answer,
     
     
    cheers
  • forstera Profile Picture
    331 on at
    Dear mmbr1606,
     
    Thanks very much for your proposition. so I pasted it to my application but I get the following error in the Lookup function :
    (I had to change the columns name to fit my sharepoint list)
     
     
    Here's my sharepoint list :
     
     
    I get some troubles with my dropBox so, for the while, I fix a value to test the whole structure :
     
     
    But I get that :
     
     
    DayNumber is unknown..
     
    Thanks very much for your help :)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    i guess it does say
     
     
    daynumber is not recognized? didnt you use this in your original code too?
     
     
    cheers
  • forstera Profile Picture
    331 on at
    yes, I used it and it seems to have worked at one point (at least this part) but I've made so many changes to my structure that I don't know when ;sorry
     
    Here's the complete structure :
     
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    Well then u simply need to Update your Code with the modification u made
  • Verified answer
    forstera Profile Picture
    331 on at
    According to this example , it seems my variables should be declared in { }
     
    With({parentRecord:LookUp(colCustomerOrder, Firstname="Sally")},
         With({orderTable:parentRecord.Orders},
              UpdateIf(orderTable, Product="DVDs", {Quantity:5});
              Patch(colCustomerOrder, parentRecord, {Orders:orderTable})
         )
    )
    So I tried to modify the structure like this and it seems to work ..
    ClearCollect(
        EmploiDuTemps;
        ForAll(
            [1; 2; 3; 4; 5];
            With(
                {
                    DayNumber: Value;
                    DayName: Switch(
                        Value;
                        1; "Lundi";
                        2; "Mardi";
                        3; "Mercredi";
                        4; "Jeudi";
                        5; "Vendredi"
                    )
                };
                {    Periods: ForAll(
                        Sequence(13; 1; 1);
                        With(
                            {
                                ClasseValue: LookUp(
                                    ListeHoraires;
                                    Colonne1 = "TR_NAN" &&
                                    Colonne4 = DayNumber &&
                                    Colonne5 = Value;
                                    Colonne3
                                )
                            };
                            {
                                Periode: Value;
                                Classe: If(IsBlank(ClasseValue); Blank(); ClasseValue);
                                Matiere: Blank();
                                Remplacant: Blank();
                                Annotation: Blank()
                            }
                        )
                    );
                    Day: DayNumber;
                    JourNom: DayName
                }
            )
        )
    )
     
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard