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 / Icon - Filters data th...
Power Apps
Answered

Icon - Filters data that is used in the next screen - Can someone explain the code?

(0) ShareShare
ReportReport
Posted on by 143

Good Morning,

 

Yep, me again.  This is the code I found to filter data based on a selection from one screen to open another.

This is the original code from the template:

 

Select(Parent);
Set(
 selectedTimeCard,
 ThisItem
);
ClearCollect(selectedTimeEntries,
Filter(
 TimeEntries,
 Title = selectedTimeCard.Title && Employee.Email = currentUser.Email
 ));
Navigate(TimeCardContinue)

 

 

I thought I understood all the variables and managed to personalize them for the next screen.  But it appears I haven't because the next screen only shows one entry in the list, and it is the same entry regardless of what option has been selected.


This is my updated code.

 

Select(Parent);
Set(
 selectedTimeCard,
 ThisItem
);
ClearCollect(colTimesheetDetails,
Filter(
 EMR_tblFinance_Timesheets_APP,
 WeekTitle= selectedTimeCard.WeekTitle && 'Employee Name'.Email = User().Email
 ));
 
Navigate(TimeCardContinue)

 

My collection is colTimesheetDetails.

My list is EMR_tblFinance_Timesheets_APP. 


I think the filter is broken or ineffective. 
I know the employee side of it works, but the title part does not.  These are the two fields that I want to use to filter the data. 

Tj7933_0-1672158551609.png

Tj7933_1-1672158570488.png

The calculation for the calculated field is: 

Tj7933_2-1672158635193.png

 

Can a collection be filtered by a calculated field? 

 

Is there anything wrong that jumps out at you?

I am so close to being finished I can taste it... 

You guys have been so supportive, talented, and useful.

Tammy

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,456 Most Valuable Professional on at

    Hi @Tj7933 ,

    Firstly, throw away that calculated field - they simply do not "play well" with Power Apps. 

    Set(
     selectedTimeCard,
     ThisItem
    );
    ClearCollect(
     colTimesheetDetails,
     Filter(
     EMR_tblFinance_Timesheets_APP,
     StartofWeek = selectedTimeCard.StartofWeek &&
     WeekEnd = selectedTimeCard.WeekEnd &&
     'Employee Name'.Email = User().Email
     )
    ); 
    Navigate(TimeCardContinue)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Tj7933 Profile Picture
    143 on at

    @WarrenBelz 

    Your code is throwing the same error.  It doesn't seem to matter how the filter is defined, PowerApps says that the CollectClear is not entered correctly.

    It says that 'CollectClear' function has some invalid arguments.  The selectedTimeCard variable is set correctly? That part is not throwing an error.
    Tj7933_0-1672183277693.png
    I erased the calculated field from the list and added a text field to capture the title. I want to allow PowerApps to fill in the formula ("Week Of: " & Text(lblWeekStart.Text), DateTimeFormat.ShortDate) & " to " &  Text(lblSelectedDate.Text), DateTimeFormat.ShortDate)"). 

    Suddenly, PowerApps reset the schema (why? I have no idea).

    Tj7933_1-1672184634958.png

     

    colTimesheetDetails is defined as below.  Please realize that every time I try to add the line for the WeekTitle text field definition, The definition for colTimesheetDetails, fails (100% red underline).

     colTimesheetDetails,
     ThisItem,
    { 'START - Date': dpStartDate_1.SelectedDate,
     StartofWeek: DateValue(lblWeekStart.Text),
     WeekEnd: DateValue(lblSelectedDate.Text),
     WeekEndNum: Text(DateValue(lblSelectedDate.Text), "yyyymmdd"),
     DayOfWeekNum:Text(DateValue(lblWeekStart.Text), "yyyymmdd"),
     'END - Date': dpEndDate_1.SelectedDate,
     'Start Hour':Value(txtStartHour_1.Text),
     'End Hour':Value(txtEndHour.Text),
     'Start - Minutes': cmbStartMinutes_1.Selected,
     'End - Minutes': cmbEndMinutes_1.Selected,
     'Non-Event Related Work Hours': Value(txtNRHours.Text),
     'Lunch Break': ckbLunch_1.Value,
     'Travel Status': ckbTravel_1.Value,
     'Lunch Delivered': ckbDeliver_1.Value,
     'Additional Information': txtDetails_1.Text,
     TimesheetUser: VarUser.Email,
     'Employee Name':{
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", 
     Claims: "i:0#.f|membership|" & Lower(User().Email),
     Department: "",
     DisplayName: User().FullName,
     Email: User().Email,
     JobTitle: "",
     Picture: ""
     }
    
     }
    );
    Collect(
     colTimesheetDetails,
     {
     'START - Date': Today(),
     WeekEndNum: Text(DateValue(lblSelectedDate.Text),"yyyymmdd"),
     WeekEnd: DateValue(lblSelectedDate.Text),
     StartOfWeek: DateValue(lblStartDate.Text),
     DayOfWeekNum: Text(DateValue(lblStartDate.Text),"yyyymmdd"),
     WeekTitle: Blank(),
     'END - Date': Today(),
     'Start Hour':0,
     'End Hour':0,
     'Start - Minutes': {Value:"00"},
     'End - Minutes': {Value:"00"},
     'Non-Event Related Work Hours': 0,
     'Lunch Break': true,
     'Travel Status': false,
     'Lunch Delivered': false,
     'Additional Information': Blank(),
     TimesheetUser: currentUser.Email,
     'Approval Status': {Value: "In Progress"}
     }
     );

     

  • Tj7933 Profile Picture
    143 on at

    @WarrenBelz 

    More details on the error that is occurring.  PowerApps indicates it is an Invalid use of a period.  Both of the top lines are getting this error.

  • Verified answer
    WarrenBelz Profile Picture
    156,456 Most Valuable Professional on at

    @Tj7933 ,

    What are the Items of the Gallery you are setting selectedTimeCard on ? The issue here is that you are setting the Variable selectedTimeCard to a Record, which needs to have StartofWeek in it and be the same field type. View the Variable (three dots at the middle top menu then Variables) then click on the "table" icon and see what it inside it.

    From your Collection code, both StartofWeek and WeekEnd should be Dates and therefore you need to ensure that the same field in the gallery data source is also a Date (I can see some Date/Text conversion going on in other places).

  • Tj7933 Profile Picture
    143 on at

    This was the problem. I did not realize that I had to define all the parts I wanted to use/transfer with the item.

    Thanks again for so much help.

    Tammy

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard