I am doing the below filter, after that I can to reach to the max value of the a particular column
My Filter of the gallery is as below and is working fine:
Sort(Filter(InqTabA,HistSearch1.Text in InqMach || HistSearch1.Text in InqSerNo),ID,Descending)
BUT I want to got the max of ID value of the filtered record.
I am aware to use Lookup(), but confused how to use the lookup along with the above
Please advise
Solved! Go to Solution.
Hi @MIA27 ,
Yes, but because you can only have one Default: value, you have to shift your Default: property from an expression to a variable. What this means is, instead of having
Last(Filter(TblMachHist,TextInput3.Text in SerialNo))
as your Default: property, you must have a variable record - which gets defined by pressing either one of two buttons. As long as that variable record points to a record that exists inside the gallery, it will work.
Set your gallery Default: property to;
varDefaultRecord
Change your button Text: to "Last record" and set its OnSelect: property to;
UpdateContext({varDefaultRecord:
Last(Filter(TblMachHist,TextInput3.Text in SerialNo))
};
Reset(MachData)
Copy and paste the button to create a new button, change it's Text: property to "First Record" and its OnSelect: property to;
UpdateContext({varDefaultRecord:
First(Filter(TblMachHist,TextInput3.Text in SerialNo))
};
Reset(MachData)
That should do it 😊
Kind regards,
RT
Hi @MIA27 ,
The Max ID of a table would be the
It looks like you're already sorting by Descending, so wrapping this inside a Last() statement should give you the record;
Last(Sort(Filter(InqTabA,HistSearch1.Text in InqMach || HistSearch1.Text in InqSerNo),ID,Descending))
and if you want a specific field from the record (like the ID);
Last(Sort(Filter(InqTabA,HistSearch1.Text in InqMach || HistSearch1.Text in InqSerNo),ID,Descending)).ID
Hope this helps,
RT
Dear Mr. Russel,
Thank you for your reply.
I applied Last and First() function, but it does the same type of result like filter.
For example to keep simple , I applied the below to test:
Last(TblMachHist) , it bring only one record instead of going to Last record
My requirement is like below screen , the user should see the screen as below (note record 266 is the last)
and once required they can roll the records up and down as normal gallery:
Just to explain you better, please note that in Access VBA we use to use a command called
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToLast
End Sub
This use to go to the last record at the same time, when required, u can roll on the records.
BUT lookup, Last, first, all these command is filtering particular records and does not allow to roll.
Please advise
Regards
Hi @MIA27 ,
So it sounds like you want the gallery to set focus on the last record - is that what you mean?
If so, then you need to set the Gallery Default: property of the Gallery to the Last() record of the table that is supplied to the Gallery Items: property, then Reset() the gallery.
So, for example, if your Items: property is on your gallery is
Sort(Filter(InqTabA,HistSearch1.Text in InqMach || HistSearch1.Text in InqSerNo),ID,Descending)
Then the gallery Default: should be set to
Last(
Sort(Filter(InqTabA,HistSearch1.Text in InqMach || HistSearch1.Text in InqSerNo),ID,Descending)
)
Then you just need an action to trigger the gallery reset in order to apply the default - you can test by adding a button and setting its OnSelect: property to
Reset(yourGallery)
The last item in the gallery should then be selected when you hit the button - if you want to be sure, you can also set the gallery TemplateFill: property to
If(ThisItem.IsSelected, LightBlue, RGBA(0, 0, 0, 0))
This will highlight the currently selected item to make it easier to see.
Hope this helps,
RT
Dear Mr. Russel,
As you mentioned, I checked with the test with simple sorting without filtering on 2 screens (one gallery with 3 records and another gallery with 266 records).
Found On On little record gallery result comes but more records gallery screen result does not show it gets done but in different way.
I will first mentioned how I tested and the result screen:
On Item for Gallery :
Sort(TblMachHist,FormNo,Ascending)
On Default For Gallery:
Last(Sort(TblMachHist,FormNo,Ascending))
On TemplateFill of the gallery :
If(ThisItem.IsSelected, LightBlue, RGBA(0, 0, 0, 0))
Made a button and Onselect :
Reset(MachData)
If the data is less -like I tested with 3 records. It open the screen and the selection is on the last record , this the result is correct:
BUT If the data is 266 records, which on opening it should be the screen - but remain as it is - Then I press the button still it remains as it is :
Now this 266 records gallery works, if I roll and remain some where to 262 records on the screen (and the 266 records can be seen on the same screen) and then press button, I find the last record got select.
I think your advise code is working but the screen does not roll to focus to the last record.
Please advise how to solve this.
Hi @MIA27 ,
Short answer is that you should apply the filter, but this may not always give you the results you expect.
Hopefully I can explain this without completely confusing you as some may be lost in translation...so I'll try avoid the complex stuff and stick to the basics;
Galleries connect to tables that come from one of two places;
For performance reasons, galleries behave differently when connected to an external source as opposed to when they are connected to a collection or a table inside PowerApps.
For example, if a gallery is connected directly to a SharePoint list (without a filter function), the gallery knows there is data transfer involved in the query, so it will try and be efficient by fetching only the first 100 rows of data to reduce performance impact.
Obviously if your source has less than 100 rows, this doesn't matter, but if it has more, the gallery will fetch the next 100 only if you continue to scroll down to the end of the gallery (you'll see the query dots run on top of the screen, then the scroll bar will jump and you'll have 100 more rows in your gallery) - if you continue scrolling the gallery will eventually get to the end of your data, even if you have 10000 rows in your source.
To get the reset working, the Default: record must exist in the current gallery dataset when reset() is called.
The reason your reset doesn't work is that your Default: expression record is at the end of the dataset, and this doesn't exist in the gallery, until all the rows have been loaded - which only happens when you scroll to the end.
So the quick solution here is probably to apply your filter function, as this automatically fetches the maximum number of rows allowed by your data row limit, instead of just the first 100. Provided the filter result does not exceed your data row limit, it will work. As soon as the filter result exceeds your data row limit, and your Default: points to a record beyond this limit, (which Last() will always do) there will be a mismatch between the Last() result applied to the dataset and the Last() result in the gallery items. This is why we apply the filter() to the last function as well, so that the resulting record is inside the same dataset returned by Items:
Note: Now, I have to warn you - there are always data row limit and delegation considerations that will affect this experience - so when your source has a large amount of rows, things start behaving quite differently - but it may be a bit much to explain for now, so I've included some links to read when you can - but just bear in mind things start to change when you have a large amount of data in your source - say > 500 rows. You can change your data row limit in your app settings to 2000, but that's the max. Eventually, you'll have to figure out the best way to filter large data sets - but for now....
The short-term solution is to try and make sure your gallery contains all the rows you're going to need up front.
You can do this by specifying a filter that only fetches the rows you need, and just make sure that same filter is applied to your Default: Last() function.
You can also Collect() the data into a collection and connect your gallery to that instead, using the collection also in your Default: Last() function.
Whatever way you choose to go about it, just remember that the resulting record from Default: must exist inside the gallery at the time of reset. When you're connecting to an external source with more than 100 rows or more than your data row limit - this may not always be the case.
Hope this helps explain somewhat - sorry if sounds complicated - but it is a little complicated 😁
Kind regards,
RT
Dear Mr. Russel,
Thank you so much for your time and details explanation which is helping me to learn more and more on powerapp.
Based on your guidance, removed the sort and performance is better.
Items: Filter(TblMachHist,TextInput3.Text in SerialNo)
Default: Last(Filter(TblMachHist,TextInput3.Text in SerialNo))
Button - Onselect : Reset(MachData)
It works, the screen opens normal, later when searched or click button from that time onward it always move to the last record, which was the requirement.
Now planning to put 2 button, one click to get the above job, and another button to reach to first record.
So user can either go to first or last based on button click.
But default can be applied once only.
Is it possible to put some code like First(Filter(TblMachHist,TextInput3.Text in SerialNo))
on the another button so that the first record get selected.
Please advise
Hi @MIA27 ,
Yes, but because you can only have one Default: value, you have to shift your Default: property from an expression to a variable. What this means is, instead of having
Last(Filter(TblMachHist,TextInput3.Text in SerialNo))
as your Default: property, you must have a variable record - which gets defined by pressing either one of two buttons. As long as that variable record points to a record that exists inside the gallery, it will work.
Set your gallery Default: property to;
varDefaultRecord
Change your button Text: to "Last record" and set its OnSelect: property to;
UpdateContext({varDefaultRecord:
Last(Filter(TblMachHist,TextInput3.Text in SerialNo))
};
Reset(MachData)
Copy and paste the button to create a new button, change it's Text: property to "First Record" and its OnSelect: property to;
UpdateContext({varDefaultRecord:
First(Filter(TblMachHist,TextInput3.Text in SerialNo))
};
Reset(MachData)
That should do it 😊
Kind regards,
RT
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08 23 @WarrenBelz 31 @DBO_DV 10 @Amik 19 AmínAA 6 @mmbr1606 12 @rzuber 4 @happyume 7 @Giraldoj 3@ANB 6 (tie) @SpongYe 6 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08 10@WarrenBelz 25 @DBO_DV 6@mmbr1606 14 @AmínAA 4 @Amik 12 @royg 3 @ANB 10 @AllanDeCastro 2 @SunilPashikanti 5 @Michaelfp 2 @FLMike 5 @eduardo_izzo 2 Meekou 2 @rzuber 2 @Velegandla 2 @PowerPlatform-P 2 @Micaiah 2 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8 SunilPashikanti8
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages