web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : KpPg/K7tX6Ibgw3ZPdYWgp
Power Apps - Building Power Apps
Unanswered

Sort columns in nested tables within a collection, create strings an sort collection

Like (0) ShareShare
ReportReport
Posted on 25 Jan 2023 13:02:26 by

Hello together, 

I am working one a solution to following issue, I just cannot figure out a working solution and hope one of you guys can help me out here:

 

I have a collection (based on a SharePointlist with choice values, multiple choices are used)

Collection name: CollectionOverview

It has three columns: Order, Country, City

in each column there are multiple rows  with nested tables, holding the multiple choices

 

 

OrderCountryCity
[Order A, Order B, Order C,  Order D][France, USA, Spain, Italy][Paris, Mobil, Bosten, Clayton, Barcelona, Rom]
[Order B, Order A][France, Germany, Austria][Paris, Berlin, Graz, Vienna, Innsbruck]
[Order D][Switzerland][Bern, Genf]
[Order A,  Order C,  Order D][Spain, Netherlands, Austria][Madrid, Venlo, Linz, Innsbruck, Vienna]

 

Now I want do create a collection which has the elements of the nested table sorted alphabetically:

OrderCountryCity
[Order A, Order B, Order C,  Order D][Italy, France, Spain, USA][Barcelona, Bosten, Clyton, Mobil, Paris, Rom]
[Order A, Order B][Austria, France, Germany][Berlin, Graz, Innsbruck, Paris, Vienna]
[Order D][Switzerland][Bern, Genf]
[Order A,  Order C,  Order D][Austria, Netherlands, Spain][Innsbruck, Linz, Madrid, Venlo, Vienna]

 

and then I want the nested tables to be transfort to strings with line breaks.

 

OrderCountryCity
Order A
Order B
Order C
Order D
Italy
France
Spain
USA
Barcelona
Bosten
Clyton
Mobil
Paris
Rom
Order A
Order B
Austria
France
Germany
Berlin
Graz
Innsbruck
Paris
Vienna
Order DSwitzerlandBern
Genf
Order A
Order C
Order D
Austria
Netherlands
Spain
Innsbruck
Linz
MadridVenlo
Vienna

 

Sample Code:

 

 

 

 ClearCollect(CollectionOverview;
{
 Order:Table( {
 value: "Order A"
 };{
 value: "Order C"
 };{
 value: "Order B"
 };{
 value: "Order D"
 });

 Country:Table( {
 value: "France"
 };{
 value: "USA"
 };{
 value: "Spain"
 };{
 value: "Italy"
 });

 City:Table( {
 value: "Paris"
 };{
 value: "Mobil"
 };{
 value: "Bosten"
 };{
 value: "Clayton"
 };{
 value: "Barcelona"
 };{
 value: "Rom"
 })
 };
{
 Order:Table( {
 value: "Order B"
 };{
 value: "Order A"
 });

 Country:Table( {
 value: "France"
 };{
 value: "Germany"
 };{
 value: "Austria"
 });

 City:Table( {
 value: "Paris"
 };{
 value: "Berlin"
 };{
 value: "Graz"
 };{
 value: "Vienna"
 };{
 value: "Innsbruck"
 })
 };
{
 Order:Table( {
 value: "Order D"
 });

 Country:Table( {
 value: "Switzerland"
 });

 City:Table( {
 value: "Bern"
 };{
 value: "Genf"
 })
 };
{
 Order:Table( {
 value: "Order A"
 };{
 value: "Order C"
 };{
 value: "Order D"
 });

 Country:Table( {
 value: "Spain"
 };{
 value: "Netherlands"
 };{
 value: "Austria"
 });

 City:Table( {
 value: "Madrid"
 };{
 value: "Venlo"
 };{
 value: "Linz"
 };{
 value: "Innsbruck"
 };{
 value: "Vienna"
 })
 }
);;

 

 

 

 

 

Solution I have so far, but I am not sure if there isn't a better way ...

 

 

// Sort and concat the Order Data
ClearCollect(CollectionOverviewOrder;
 ForAll(CollectionOverview; Concat(Sort(ThisRecord.Order;value;Ascending);ThisRecord.value; "
 ")
));;

// Sort and concat the Country Data
ClearCollect(CollectionOverviewCounty;
 ForAll(CollectionOverview; Concat(Sort(ThisRecord.Country;value;Ascending);ThisRecord.value; "
 ")
));;

// Sort and concat the City Data
ClearCollect(CollectionOverviewCity;
 ForAll(CollectionOverview; Concat(Sort(ThisRecord.City;value;Ascending);ThisRecord.value; "
 ")
));;

// Combine Order, Country and City Data
ClearCollect(CollectionOverviewAll; 
 ForAll(Sequence(CountRows(CollectionOverviewOrder));
 {
 Order: Index(CollectionOverviewOrder;Value).Value;
 Country: Index(CollectionOverviewCounty;Value).Value;
 City: Index(CollectionOverviewCity;Value).Value
 }
 )
)

 

 

 

 

Categories:

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete