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 / Error with collection
Power Apps
Answered

Error with collection

(1) ShareShare
ReportReport
Posted on by 297
Hi all, 
 
I'm having issues and wondered if there's anything obvious? the varSelectDate is from the on change of my date picker,  
 
If(ctxLoadPeople,
//Load People
ClearCollect(colPeople,
AddColumns(Sort(EngineerNames,FullName) As Contact,
Zone,
"People",
PersonaImage,
    If(!IsBlank(Contact.EntitiyImage),Substitute(JSON(Contact.EntitiyImage.Value,JSONFormat.IncludeBinaryData),"""","")),
 
    Initials,
    Mid(Contact.'First Name',1,1) & Mid(Contact.'Last Name',1,1)
    )
);
UpdateContext({ctxLoadPeople:false});
 
If(ctxLoadDaySlots,
// Create Day Slots
ClearCollect(
    colDaySlots,
    ForAll(
        colPeople As Person,
        {
            Person: Person,
            Days: ForAll(
                Sequence(DaysinRange) As Day,
                {
                    PersonId: Person.FullName,
                    Day: Day.Value,
                    Zone: $"{Day.Value}|{Person.FullName}"
                }
            )
        }
    )
);
UpdateContext({ctxLoadDaySlots:false});
 
If(ctxTaskEvent,
ClearCollect(
    ColTasks,
    AddColumns(
        ProjectTasks,
        TaskName,JobDetails,
        Zone,
        If(IsBlank('Assigned To'),
        "Unassigned",
        $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
       
        ),
         Edited,false
    )
);
UpdateContext({ctxTaskEvent:false});
);
 
 
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Assuming that the two values in the DateDiff are correctly formatted dates.
    Datediff returns a number. Thought it would convert it to text. Try adding a Text function around it to convert it to text 
  • jsmith87 Profile Picture
    297 on at
    Hi, 
     
    from watching the video i'm following, https://www.youtube.com/watch?v=wkHvjusgLEE&t=326s the part is 5:14 
     
    what i'm trying to achieve is to create a unique ID with the first part being a date from my dataverse column Due Date and then a | with the second part being a persons name so i should have something like
     
    28/01/2025|John Smith
     
    the thing i can't figure out from the video is where he's got that variable from. I only have a date picker and a label which have anything to do with date. I'll add the code for them further down. 
     
    $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
     
     
    from label
    Text(DateAdd(DatePickerCanvas1.SelectedDate,ThisItem.Value-1,TimeUnit.Days),DateTimeFormat.ShortDate)
     
    from date picker
    Select(fnLoadTasks_2)
  • Suggested answer
    stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
     
    1.  I think in your code, you assigned JobDetails to TaskName. do you mean TaskName, "TaskName",JobDetails,"JobDetails" ?
    2.  $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
      1. {DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}, looks correct,you have to make sure VarSelectedDate and 'Due Date' is the same date type, this one return a integer.
      2.  'Assigned To'.Contact, this part you have to make sure it is a text.
    try those checks first.
    good luck.
  • jsmith87 Profile Picture
    297 on at
    Hi Stampcoin, 
     
    Thanks for the tips, still no joy (it's certainly me!)
     
    following your advice I went back to my dataverse table and added a date column. Which I have named Due date. So with varSelectedDate coming from my data picker and having a dataverse table column with date fomat they should be both the same however i am getting the below error. 
     
    Also regarding JobDetails to TaskName. do you mean TaskName,"TaskName",JobDetails,"JobDetails" ?
     
    I honestly don't know, I thought following a video step by step to enhance my knowledge would be a good way to learn. I was wrong.... in my dataverse fields i have:
     
    I think what the video is trying to achieve is that if in the dataverse table someone's name is in the assigned to and there's a date it will combine them both with | between the name and date. Does this help at all?
     
     
  • jsmith87 Profile Picture
    297 on at
    I think it's certainly my variable, but don't know how to resolve. When i hover over the error i get this 
     
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Did you start from the first video to build it and follow the Github notes?
  • jsmith87 Profile Picture
    297 on at
    Hi yes, i'm on the third video all is working as it should till this particular item
  • Suggested answer
    stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    some tips:
    1. make sure VarSelectedDate,'Due Date' both are date type, you can add a label, and assign the label text= VarSelectedDate, another label, assign text='Due date'. the purpose is to identify both have the correct data
    2. identify 'Assigned To'.Contact} make sure it is text type value.
    3. another easy way is like this:
      $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{"John Doe"}"
    then you will know which part has problem.
    feel free if you need more help.
  • jsmith87 Profile Picture
    297 on at
     thank you that's working now, the only issue is that Contacts are a table i believe and the dates need to be changed to text. I don't suppose you'd be ok with a call to help me resolve this issue? if that's ok i'd really appreciate it, i'm sure it's something you'd be able to resolve in seconds 
     
    If(ctxLoadPeople,
    //Load People
    ClearCollect(colPeople,
    AddColumns(Sort(EngineerNames,FullName) As Contact,
    Zone,
    "People",
    PersonaImage,
        If(!IsBlank(Contact.EntitiyImage),Substitute(JSON(Contact.EntitiyImage.Value,JSONFormat.IncludeBinaryData),"""","")),
     
        Initials,
        Mid(Contact.'First Name',1,1) & Mid(Contact.'Last Name',1,1)
        )
    ));
    UpdateContext({ctxLoadPeople:false});
     
    If(ctxLoadDaySlots,
    // Create Day Slots
    ClearCollect(
        colDaySlots,
        ForAll(
            colPeople As Person,
            {
                Person: Person,
                Days: ForAll(
                    Sequence(DaysinRange) As Day,
                    {
                        PersonId: Person.FullName,
                        Day: Day.Value,
                        Zone: $"{Day.Value}|{Person.FullName}"
                    }
                )
            }
        )
    ));
     
    If(ctxTaskEvent,
    ClearCollect(
        ColTasks,
        AddColumns(
            ProjectTasks,
            TaskName,"JobDetails",
            Zone,
           
            If(IsBlank('Assigned To'),
            "Unassigned",
    $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{"John Doe"}"
         
            ),
             Edited,false
        )
    );
    UpdateContext({ctxTaskEvent:false});
    );
  • Verified answer
    stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    I am heading for lunch... here is an reference for you.
    NewColumn, $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{'Status (Contacts)'.Active}"
     
    'Assigned To'.Contact, is this correct format ( didn't watch the video...).
    the format should be columnname(tableName).value ( see my example), or some property you can refer to.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard