cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KimberlyM
Level 8

Filter loading too much data

This code is loading the newest item and the correct ID item into my gallery. Why? How do I get it to stop loading the newest item?

This is only happening when I click on the deep link in the email produced by PowerApps.

I believe this to say: filter this gallery with lead_history information where the LeadID column equals the selected id from Gallery_Dashboard OR where the LeadID column equals the parameter passed in the URL called ID.

SortByColumns(
    Filter(
        Lead_History,
        Or(
        LeadID = Gallery_Dashboard.Selected.ID,
        LeadID = Value(Param("ID")))
    ),
    "HistoryDate",
    SortOrder.Descending
)

  

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filter loading too much data

Hi @KimberlyM ,

Based on the formula you provided, I think there is something wrong with it.

 

I have made a test on my side, please consider take a try with the following workaround:

1. Set the OnStart property of App to following:

If(
    !IsBlank(Param("ID")),
    Set(CurrentID, Value(Param("ID")))
);
If(
   !IsBlank(CurrentID),
   Navigate(Edit, ScreenTransition.Fade)
)

2. Set the Item property of the Edit form to following:

If(
    !IsBlank(CurrentID),
    LookUp(Lead_Data, ID = CurrentID),
    Gallery_Dashboard.Selected
)

 

3. Set the Items property of the nGallery_History to following:

If(
    !IsBlank(CurrentID),
    SortByColumns(
                  Filter(Lead_History, LeadID = CurrentID),
                  "HistoryDate",
                  SortOrder.Descending
    ),
    SortByColumns(
                  Filter(Lead_History, LeadID = Gallery_Dashboard.Selected.ID),
                  "HistoryDate",
                  SortOrder.Descending
    )
)

 

4. Add the following formula within the OnSelect property of the Gallery_Dashboard or the OnSelect proeprty of the ">" icon within your Gallery_Dashboard:

Set(CurrentID, Blank())

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Filter loading too much data

Hi @KimberlyM ,

Could you please share a bit more about your scenario?

Could you please share more details about "How do I get it to stop loading the newest item"? What do you mean?

 

Based on the formula you provided, it would retrieve data from your Lead_History, where LeadID column matches the selected item id value from your Gallery_Dashboard or the ID value passed from the email link in your email body.

 

If you want to remove the newest item from the retrieved result, please consider take a try with the following workaround:

FirstN(
       SortByColumns(
              Filter(
                      Lead_History,
                      If(
                          !IsBlank(Param("ID")),
                           LeadID = Value(Param("ID")),
                           LeadID = Gallery_Dashboard.Selected.ID
                      )
              ),
              "HistoryDate",
              SortOrder.Ascending
        ),
        CountRows(Filter(Lead_History, If(!IsBlank(Param("ID")), LeadID = Value(Param("ID")), LeadID = Gallery_Dashboard.Selected.ID))) - 1
)

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
KimberlyM
Level 8

Re: Filter loading too much data

@v-xida-msft thank you for responding. This did not help me as nothing would load into my gallery (it showed blank) and I also need to stay away from delegation warnings as my SharePoint list will grow to be quite large.

Here are more details on what I am trying to accomplish:

I call this screen my correct screen. When I open a specific item into the edit screen from my dashboard my details load correctly as I expect. Here you will see fuzzy data and where my gallery (name is nGallery_History - loading the Lead_History SharePoint list) at the bottom page for this specific ID (157 from my SharePoint List). 
oct29_correcteditview.jpg

When I load the app from the deep link created from PowerApps (the app sends an email when a new lead is created with a link to the edit page where it opens the specific Lead ID). As you will see in this screen shot it is loading the same information as above. My form loads correctly. However, my gallery is loading the Lead_History SharePoint list data for ID 157 and 158, where 158 is the last item added to the SharePoint list.
oct29_wrongeditview.jpg

I only want the form and gallery on this screen (Edit) to load one ID number.


Here is my code I've got so far to make this work:

HTML Link from email:

 

<a href="https://apps.powerapps.com/play/100f3eb7-fc43-4283-a057-aa38a130ca6e?tenantId=d484a071-daef-44c2-a8c4-6bcb3df97dee&amp;ID=157">VIEW LEAD
</a>

 


App OnStart:

 

/ALLOWS USER TO CLICK ON DEEP LINK SENT IN INITAL EMAIL AND LOAD THE DIRECT LEAD
If(!IsBlank(Param("ID")), Set(varRecordToOpen, First(Filter(Lead_Data, ID=Value(Param("ID")))))); 

 

 
First Screen Loaded - Timer:
Duration: 

 

600

 

OnTimerEnd:

 

If(!IsBlank(Param("ID")),Navigate(Edit, ScreenTransition.Fade,{LoadLead: LookUp(Lead_Data, ID = Value(Param("ID")))}));

 

 
Edit Screen:
Form - Item:

 

varRecordToOpen

 

 Gallery (nGallery_History):

 

SortByColumns(
    Filter(
        Lead_History,
        Or(
            LeadID = Gallery_Dashboard.Selected.ID,
            LeadID = Value(Param("ID"))
        )
    ),
    "HistoryDate",
    SortOrder.Descending
)

 

 

From my dashboard (in case this helps) my button to link to the Edit screen that loads the form and nGallery_History correctly has this set on its OnSelect property:

 

Select(Parent);
Set(CurrentSelectedItem,ThisItem);
ClearCollect(col_History, {LineItem: "", LineDate: "", ShowSaveButton: true});

 

 
I think this has everything and I am hoping you can help me with this problem. I am looking forward to wrapping this project up! 🙂 Thank you again! I am very grateful for your time and help!

KimberlyM
Level 8

Re: Filter loading too much data

Would it make sense that my OnStart of the app is the problem because I am using the formula:

 

If(!IsBlank(Param("ID")), Set(varRecordToOpen, First(Filter(Lead_Data, ID=Value(Param("ID")))))); 

 

 
I think First would be what is pulling the extra data but I am not sure (through much trial and error) what to replace First with.

If I remove First it causes an error on my Edit form with the variable being called varRecordToOpen. 
I am not really understanding this line of code and that is why I am struggling with it.

If the Parameter is not empty then make a variable called varRecordToOpen and filter Lead_Data to show where the column ID equals the parameter ID. (As you can see here I have skipped over the first as I don't know how to "read" it in context to the formula. I do believe it is saying to load the the first item in the list though but then I don't understand why it needs to be there because I don't need the first item in the list to load, I need the matching IDs to load. And there is the inner working of my brain for you! 🙂

Community Support Team
Community Support Team

Re: Filter loading too much data

Hi @KimberlyM ,

Based on the formula you provided, I think there is something wrong with it.

 

I have made a test on my side, please consider take a try with the following workaround:

1. Set the OnStart property of App to following:

If(
    !IsBlank(Param("ID")),
    Set(CurrentID, Value(Param("ID")))
);
If(
   !IsBlank(CurrentID),
   Navigate(Edit, ScreenTransition.Fade)
)

2. Set the Item property of the Edit form to following:

If(
    !IsBlank(CurrentID),
    LookUp(Lead_Data, ID = CurrentID),
    Gallery_Dashboard.Selected
)

 

3. Set the Items property of the nGallery_History to following:

If(
    !IsBlank(CurrentID),
    SortByColumns(
                  Filter(Lead_History, LeadID = CurrentID),
                  "HistoryDate",
                  SortOrder.Descending
    ),
    SortByColumns(
                  Filter(Lead_History, LeadID = Gallery_Dashboard.Selected.ID),
                  "HistoryDate",
                  SortOrder.Descending
    )
)

 

4. Add the following formula within the OnSelect property of the Gallery_Dashboard or the OnSelect proeprty of the ">" icon within your Gallery_Dashboard:

Set(CurrentID, Blank())

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

KimberlyM
Level 8

Re: Filter loading too much data

@v-xida-msft thank you again for your help and time! I am so happy that this has been resolved! The changes you suggested make complete sense to me and reads so much simpler to me! Thank you for helping me learn and improve myself!

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,218)