cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shekinah
Frequent Visitor

How to add a descending filter in my gallery with If

Hello, I've been using Power Apps for a while and I can't filter my gallery in descending order,

indeed I have already filtered the gallery by status with IF but each time I want to add this

: SortByColumns('DataSource'; "ID"; Descendant) 

 

I have some errors can someone help me please

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Shekinah ,

Something like this should do it

SortByColumns(
   Filter(
      'Demande frais - Remboursement';
      'Créé par'.Email = VarUserEmail &&
      Switch(
         varTabSelected;
         1;
         Statut.Value = "" || Statut.Value = "Nouveau";
         2;
         Statut.Value = "En cours";
         3;
         Statut.Value = "Refusé";
         4;
         Statut.Value = "Validé" && 'Etape en cours'.Value = "prêt pour payement";
         5;
         Statut.Value = "Validé" && 'Etape en cours'.Value = "clôturée"
      )
   );
   "ID";
   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.

Visit my blog Practical Power Apps

View solution in original post

8 REPLIES 8
WarrenBelz
Super User
Super User

@Shekinah 

From what you posted, 

SortByColumns(
   'DataSource'; 
   "ID"; 
   Descending
) 

should be correct. If you want it added to the code in your image, please post this code in Text.

 

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.

Visit my blog Practical Power Apps

 

 

 

phipps0218
Super User
Super User

@Shekinah, the only issue is your semi-colons and Descending spelling. It should be:

 

SortByColumns(
   'DataSource', 
   "ID", 
   Descending
) 

 

 

I hope this helps!

 

Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218

@phipps0218 ,

That is European syntax and is valid in that region.

Hello @WarrenBelz ,

exactly I would like to add it to this code. how to achieve it

 

Here is the code in question

If(
varTabSelected=1;
Filter(
'Demande frais - Remboursement';
Statut.Value = "" Or Statut.Value = "Nouveau" && 'Créé par'.Email = VarUserEmail
);
varTabSelected = 2;
Filter(
'Demande frais - Remboursement';
Statut.Value = "En cours" && 'Créé par'.Email = VarUserEmail
);
varTabSelected = 3;
Filter(
'Demande frais - Remboursement';
Statut.Value = "Refusé" && 'Créé par'.Email = VarUserEmail
);
varTabSelected = 4;
Filter(
'Demande frais - Remboursement';
Statut.Value = "Validé" && 'Etape en cours'.Value = "prêt pour payement" && 'Créé par'.Email = VarUserEmail
);
Filter(
'Demande frais - Remboursement';
Statut.Value = "Validé" && 'Etape en cours'.Value = "clôturée" && 'Créé par'.Email = VarUserEmail
)
)

 

 

Thank you!

Hi @Shekinah ,

Something like this should do it

SortByColumns(
   Filter(
      'Demande frais - Remboursement';
      'Créé par'.Email = VarUserEmail &&
      Switch(
         varTabSelected;
         1;
         Statut.Value = "" || Statut.Value = "Nouveau";
         2;
         Statut.Value = "En cours";
         3;
         Statut.Value = "Refusé";
         4;
         Statut.Value = "Validé" && 'Etape en cours'.Value = "prêt pour payement";
         5;
         Statut.Value = "Validé" && 'Etape en cours'.Value = "clôturée"
      )
   );
   "ID";
   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.

Visit my blog Practical Power Apps

I have error messages like this

 

Number of invalid arguments: 1 were received, 2 or more were expected. The 'SortByColumns' function contains invalid arguments.
The name is not valid. "Status" is not recognized.

Thanks it worked

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,296)