I have a "parent" list that collects the basic details about someone's foreign travel trip (name of traveler, reason for travel) and a "child" list that stores the individual legs of their trip (location and dates), where the ID of the parent is stored in a column called MasterID. Here is a screenshot of the child list (we have to use SharePoint as our data source):
In my Power App I want a filtered gallery that shows current and upcoming trips, and I want to be able to sort it by 'Date Outgoing Departure' in descending order...but I also want to group the results so each trip has only one row in the gallery. That row will concatenate the values of all of the countries they are visiting and find the date range of their trip. For example (and yes, I know that only MasterID #1 is current or upcoming travel as of today's date but let's pretend I posted this question in early November):
MasterID | Countries Visiting | Dates of Travel | Status464 |
1 | France, United Kingdom of Great Britain and Northern Ireland (the), Antarctica, Australia | 11/17/2023 - 1/4/2024 | Submitted |
2 | Italy | 11/27/2023 - 11/30/2023 | Submitted |
3 | Angola | 11/14/2023 - 11/29/2023 | Submitted |
What I cannot figure out is how to accomplish what I want without worrying about delegation. It seems like if I use "Distinct" or "Collect" or "GroupBy" everything is going to be subject to delegation. I don't expect for there to ever be more than 500 trips in our system that are occurring currently or in the future, but I'm not sure of how to correctly filter the data AND get the distinct values I'm looking for. Maybe I'm misunderstanding delegation.
Here's what I have right now...
Items property of my gallery:
With(
{
wItineraryFiltered: Filter(
'usm464-travelitinerary',
Status464 = "Submitted" And 'Date Return Arrival' > DateAdd(
Today(),
-1,
TimeUnit.Days
)
)
},
Distinct(
wItineraryFiltered,
MasterID
)
)
This just returns this (given today's date is 12/27/2023) - only MasterID #1 with my current test data:
Then to concatenate the values of countries being traveled to (separated by a comma), here's what I have for the COUNTRY TO label in the gallery:
Concat(
SortByColumns(
Filter(
'usm464-travelitinerary',
MasterID = ThisItem.Value
),
"Date_x0020_Outgoing_x0020_Depart",
SortOrder.Ascending
),
Country_x0020_TO,
", "
)
And this is what I have for the TRAVEL DATES label in the gallery:
With(
{
wTripID: Filter(
SortByColumns(
'usm464-travelitinerary',
"Date_x0020_Outgoing_x0020_Depart",
SortOrder.Ascending
),
MasterID = ThisItem.Value
)
},
First(wTripID).Date_x0020_Outgoing_x0020_Depart & " - " & Last(wTripID).Date_x0020_Return_x0020_Arrival
)
I was all excited because this DOES work to display the data...until I realized that there's no way for me to now sort the gallery with 'Date Outgoing Departure' in descending order because the Items property of the gallery is only returning a "Value" column that has the MasterID values.
And if I wanted to add a filter option to allow someone to filter the gallery to see upcoming trips to a specific country, that also wouldn't be possible with my current set up.
What is the correct way for me to handle these requirements?? Any guidance would be greatly appreciated! Thanks in advance!
Solved! Go to Solution.
Even though this is NOT the look that I wanted, it seems to be the only way to handle this so this is what I have resorted to doing...nested galleries.
1. Main flexible height vertical gallery - Items property:
ShowColumns(
Sort(
Filter(
'usm464-travelitinerary',
Status464 = "Submitted" And 'Date Return Arrival' > DateAdd(
Today(),
-1,
TimeUnit.Days
) && (Len(cbFilter_Country.Selected.Name) = 0 || 'Country TO' = cbFilter_Country.Selected.Name)
),
'Date Outgoing Departure',
SortOrder.Descending
),
"MasterID"
)
This gets me the list of unique MasterIDs from trips that are ongoing and in the future.
Nested flexible height gallery #1 - positioned just to the right of the label in the "parent" gallery - Items property:
Filter(usm464, ID = ThisItem.MasterID)
This allows me to display information from the parent list like the name of the traveler:
ThisItem.'First Name' & " " & ThisItem.'Last Name'
Nested flexible height gallery #2 - positioned underneath nested gallery #1 - Items property:
Filter('usm464-travelitinerary', MasterID = ThisItem.MasterID)
This results in this design:
The country filter now has a note next to it that explains that it will only return records where the travel is current or future to the country the user is searching for. If I filter by "France" it will not return Trip ID #1, but if I search for Australia it will show the entire Trip #1 record. This should be sufficient for most cases, and if the program managers need to see a list of all past travel to a specific country then we can pull that up in a separate view that is filtering only based on the country name.
Thanks for all of your help on this @WarrenBelz, I really appreciate it!
Hi @NickiPT ,
Firstly, this will sort before the values are grouped and also add a filter for your country (xxxx is Value or the field name depending on your Items)
With(
{
wItineraryFiltered:
Sort(
Filter(
'usm464-travelitinerary',
Status464 = "Submitted" &&
'Date Return Arrival' >
DateAdd(
Today(),
-1,
TimeUnit.Days
) &&
(
Len(YourCountryDropdown.Selected.xxxx) = 0 ||
Country = YourCountryDropdown.Selected.xxxx
)
),
'Date Outgoing Departure',
SortOrder.Descending
)
},
GroupBy(
wItineraryFiltered,
"MasterID",
"Grouped"
)
)
Next your Countries can be
Concat(
SortByColumns(
ThisItem.Grouped,
"Date_x0020_Outgoing_x0020_Depart",
SortOrder.Ascending
),
Country_x0020_TO,
", "
)
and your Dates
First(ThisItem.Grouped).Date_x0020_Outgoing_x0020_Depart & " - " & Last(ThisItem.Grouped).Date_x0020_Return_x0020_Arrival
You will find the last two far more efficient as previously, you were making two calls to the data source for every record (now is is all local)
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
@WarrenBelz - thank you very much! I hadn't been sure how to reference the data in the table within a GroupBy function so your answer is enlightening!
However, the results that are returned in my gallery are now only the Antarctica and Australia trips which are still within the bounds of the "Date Return Arrival is today or later" filter criteria. (And if I check it tomorrow it would only show Australia because we will be past 12/28/2023.) Because I need to pull in all legs of the ongoing trip to include ones that have already passed, it seems that I need two queries: one to get the MasterID of trips with ongoing leg(s), and then another to get ALL rows associated with that trip.
I played around with creating a collection OnVisible of the screen to get a list of the MasterIDs that meet the criteria but then using filter criteria on the gallery with "MasterID in colItineraryData.MasterID" has a delegation warning of course...
@NickiPT ,
I was using your filter and assumed you wanted present and future items. I suggest you put in a Text Input formatted to numeric with a Default of 1 and allow the user to choose how many days in the past to show. To get rid of the Delegation warning and do this
With(
{
_Date:
DateAdd(
Today(),
Value(YourDaysTextBox.Text),
TimeUnit.Days
)
},
With(
{
wItineraryFiltered:
Sort(
Filter(
'usm464-travelitinerary',
Status464 = "Submitted" &&
'Date Return Arrival' > _Date &&
(
Len(YourCountryDropdown.Selected.xxxx) = 0 ||
Country = YourCountryDropdown.Selected.xxxx
)
),
'Date Outgoing Departure',
SortOrder.Descending
)
},
GroupBy(
wItineraryFiltered,
"MasterID",
"Grouped"
)
)
)
BTW - I assume from the flight schedule you work for/with Air NZ over the ditch.
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
@WarrenBelz Ha... I wish I worked for Air NZ - that sounds it would be like a fun job!
The "current and future" filter is accurate but only to the extent that it is needed to determine which trips (not legs) need to be seen. For example:
Trip #1:
I need this trip because while France and Germany are now in the past, the Spain leg is still current/future. We are not treating the trip's legs as separate info that has to be pulled - we need to see someone's entire international travel trip overview from start to finish. So I want to return MasterID #1 in this case and have one row for it like this:
MasterID | Countries | Travel Dates |
1 | France, Germany, Spain | 12/20 - 1/3 |
A trip with ALL legs in the past would not need to be shown in my gallery in order to limit the amount of trips the management pulls into the app. (I plan to have another screen where they can search for a specific past trip using filters if needed.)
@NickiPT ,
Now this is getting complex - try this
With(
{
_Date:
DateAdd(
Today(),
Value(YourDaysTextBox.Text),
TimeUnit.Days
)
},
With(
{
wItineraryFiltered:
Sort(
Filter(
'usm464-travelitinerary',
Status464 = "Submitted" &&
'Date Return Arrival' > _Date &&
(
Len(YourCountryDropdown.Selected.xxxx) = 0 ||
Country = YourCountryDropdown.Selected.xxxx
)
),
'Date Outgoing Departure',
SortOrder.Descending
)
},
AddColumns(
GroupBy(
wItineraryFiltered,
"MasterID",
"Grouped"
),
"Countries",
Concat(
Grouped,
Country,
", "
),
"Dates"
With(
{
_Date1:
Sort(
Grouped,
'Date Outgoing Departure',
SortOrder.Ascending
),
_Date2:
Sort(
Grouped,
'Date Return Arrival',
SortOrder.Descending
)
},
Text(
First(_Date1).'Date Outgoing Departure',
"dd/mm/yyyy"
) &
" - " &
Text(
First(_Date2).'Date Return Arrival',
"dd/mm/yyyy"
)
)
)
)
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
@WarrenBelz - It's yelling at me after I get past the With statements at the "AddColumns" section of the statement. I am signing off work right now and will tackle this again after the holiday (will post any solution if I am able to come up with it). Thanks for your continued assistance with this nightmare of a gallery and happy new year!
@NickiPT ,
I free-typed that without testing - strange but it did not like the Sort function inside the AddColumns, so I moved it outside. I updated the original rather than re-post all of that.
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
@WarrenBelz - Happy new year!
I was still having issues at the AddColumns part of the formula so I messed around with it all day and finally came up with something that seems to work. Please let me know if it seems that delegation will be an issue with this solution!
OnVisible of my screen (and on a "reload" icon on the screen as well):
//Get a unique list of the MasterIDs for ongoing and future trips where at least 1 trip leg is today or later
ClearCollect(
colItineraryIDs,
ShowColumns(
Filter(
'usm464-travelitinerary',
Status464 = "Submitted" And 'Date Return Arrival' > DateAdd(
Today(),
-1,
TimeUnit.Days
)
),
"MasterID"
)
);
This currently returns 2 trips (I added one this morning):
Then the Items property of my gallery is:
Sort(
With(
{
wItineraryFiltered: Sort(
Filter(
'usm464-travelitinerary',
MasterID in colItineraryIDs[@MasterID] && (Len(cbFilter_Country.Selected.Name) = 0 || 'Country TO' = cbFilter_Country.Selected.Name)
),
'Date Outgoing Departure',
SortOrder.Ascending
)
},
AddColumns(
GroupBy(
wItineraryFiltered,
"MasterID",
"Grouped"
),
"Countries",
Concat(
Grouped,
'Country TO',
", "
),
"DateDeparture",
First(Grouped.Date_x0020_Outgoing_x0020_Depart).'Date Outgoing Departure',
"DateReturnArrival",
Last(Grouped.Date_x0020_Return_x0020_Arrival).Date_x0020_Return_x0020_Arrival
)
),
DateDeparture,
SortOrder.Descending
)
Which results in:
And then for the labels in my gallery I can now reference these values:
ThisItem.Countries
ThisItem.DateDeparture & " - " & ThisItem.DateReturnArrival
I am getting a delegation warning in the Items property where I am using "MasterID in colItineraryIDs[@MasterID]" -- but if my "colItineraryIDs" collection, which is filtered, is fewer than 500 results then I should be fine, right? (Please say yes, please say yes 😂)
Hi @NickiPT ,
Yes if you have fewer than 500 records in 'usm464-travelitinerary', then it should work. I tend to do the below for smaller lists as I do not like errors or warnings anywhere in my apps (so if one comes up, it is a real issue). This only masks the warning and does not make it Delegable.
With(
{_Ininerary: 'usm464-travelitinerary'},
Sort(
With(
{
wItineraryFiltered:
Sort(
Filter(
_Ininerary,
MasterID in colItineraryIDs[@MasterID]
),
'Date Outgoing Departure',
SortOrder.Ascending
)
},
AddColumns(
GroupBy(
wItineraryFiltered,
"MasterID",
"Grouped"
),
"Countries",
Concat(
Grouped,
'Country TO',
", "
),
"DateDeparture",
First(Grouped.Date_x0020_Outgoing_x0020_Depart).'Date Outgoing Departure',
"DateReturnArrival",
Last(Grouped.Date_x0020_Return_x0020_Arrival).Date_x0020_Return_x0020_Arrival
)
),
DateDeparture,
SortOrder.Descending
)
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
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