cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sajarac
Kudo Kingpin
Kudo Kingpin

Sorting a gallery based on Multiple conditions

Hi there, quick question here:

 

Currently I have the items in my gallery as follow:

 

Sort(Filter(LIPDatabase,CustomerID=varCustomerID),ID,Descending)

 

Also I have a toggle in the same gallery and I would like to add the toggle condition to my filter.

 

I would like to see in that gallery if the toggle value is true.

 

could someone please give me an advice?

 

thank you

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@sajarac 

You can't have a toggle IN your gallery directly impact your Items of your Gallery (this will come as a circular reference).

If your toggle is outside of the Gallery this is no problem.

Now, if your Toggle is based on a column in your datasource, then you can filter on that.  So, for example, if the datasource has a yes/no column called toggleYesNo, then you can change your filter to the following:

Sort(
    Filter(LIPDatabase,
        CustomerID = varCustomerID &&
        toggleYesNo
    ),
    ID,
    Descending
)

This will return all the rows where the criteria for customer id matches and the toggleYesNo column is equal to true.

 

NOW...before going any further, there is an issue with filtering on Yes/No columns.  So, I need to ask if that is what you are actually referring to in your description of the problem you have.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

9 REPLIES 9
RandyHayes
Super User III
Super User III

@sajarac 

You can't have a toggle IN your gallery directly impact your Items of your Gallery (this will come as a circular reference).

If your toggle is outside of the Gallery this is no problem.

Now, if your Toggle is based on a column in your datasource, then you can filter on that.  So, for example, if the datasource has a yes/no column called toggleYesNo, then you can change your filter to the following:

Sort(
    Filter(LIPDatabase,
        CustomerID = varCustomerID &&
        toggleYesNo
    ),
    ID,
    Descending
)

This will return all the rows where the criteria for customer id matches and the toggleYesNo column is equal to true.

 

NOW...before going any further, there is an issue with filtering on Yes/No columns.  So, I need to ask if that is what you are actually referring to in your description of the problem you have.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

sajarac
Kudo Kingpin
Kudo Kingpin

Hi, thank you very much for your prompt response, here is what I get:

 

sajarac_0-1614696551538.png

 

And this is my SPL column:

sajarac_1-1614696577475.png

 

RandyHayes
Super User III
Super User III

@sajarac 

Okay...the blue underlines are only a delegation warning.  If your list is not expected to exceed 2000 items, you can ignore it.

 

But, confirmed that you are using a Yes/No column.  

So, PowerApps has a long running bug in regard to filtering by Yes/No columns.  There are workarounds for it, but the better solution is to utilize either a text column or a number column to take the place of it.

For example - a text column which you would set with either "Yes" or "No" would allow you to filter for those text values.

Or (and my personal preference) a number column with 0 for false and 1 for true is also something you can easily filter for.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
sajarac
Kudo Kingpin
Kudo Kingpin

Yes, I am using a Y/N column, because I need that the user quickly switch between values, but I can definitely change for a Text line in Sharepoint and add a dropdown in my Gallery if this is a better way?

RandyHayes
Super User III
Super User III

@sajarac 

You can still utilize a toggle in your app for this column.  The only difference is that you are writing either a 0 or a 1 depending on the toggle (or text yes no).

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
sajarac
Kudo Kingpin
Kudo Kingpin

But if I do that I will get this error?

 

sajarac_0-1614698718296.png

I have added a new text column "GalleryPosition"

 

I have changed the default to thisitem.Galleryposition and I am getting that.

 

😞

RandyHayes
Super User III
Super User III

@sajarac 

What did you change the GalleryPosition column to in your list?

If it is text and you have Yes and No in the text, then your Default should be : ThisItem.GalleryPosition="Yes"

If you changed it to a number and 0 is false and 1 is true, then your Default should be: ThisItem.GalleryPosition = 1

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
sajarac
Kudo Kingpin
Kudo Kingpin

THANK YOU !!!

RandyHayes
Super User III
Super User III

@sajarac 

Wow...that's a BIG thank you!  😂

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (46,948)