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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sorting on a Variable ...
Power Apps
Unanswered

Sorting on a Variable and a Toggle

(0) ShareShare
ReportReport
Posted on by 74

Hello All!

I am waste deep in building my own PowerApps for my company now that I have found this community and YouTube Videos by Shane Young, and have endless amounts of learning material and resources at my fingertips.  Throughout all my google searches and video watching, I simply cannot solve this filter problem I am having.  I do not get errors in my code, nor does the code ACTUALLY work though....

I have a gallery that I need to see items in 'Projects' based on the logged in user (varCurrentUserEmail) AND whether the 'Approval' toggle field on the item is true or false.  I have tried these to no errors or avail:

Sort(Filter(Projects, Approver.Email=varCurrentUserEmail && Approval=true), ID, Descending)

Sort(Filter(Projects, Approver.Email=varCurrentUserEmail && Approval=false), ID, Descending)

Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, Approval=true), ID, Descending)

Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, Approval=false), ID, Descending)

All 4 of these ONLY return records that 'approver = logged in user' and 'Approval = False'.  It seems that it is completely bypassing the "Approval=true" in all cases?  I pounded my head on my desk for awhile and cannot figure it out.  It HAS to be simple... right?

It's giving me errors if using Approval.Value, Approval.TrueText and other more defining names with equaling "true", "Yes", etc, but I think I am barking up the wrong tree on those.

 

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @csheets 

    The formula you want to build would look something like this:

    Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, Approval=toggle_Approved.Value), your_field_name, Ascending)

     

    I made these changes:

    • Added a 2nd and 3rd argument for SORT which was missing
    • Made a reference to the toggle instead of hardcoding true or false

     

    This solution work typically work if your datasource is SharePoint and your Approval column is a Yes/No data type.  Does your situation match this description? 

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • csheets Profile Picture
    74 on at

    @mdevaney 

    Sorry, added the last bit of code to follow the sort on my examples.  I was in a rush to copy/paste those that I missed them!

    So you are saying that it needs to look like this?

     

    Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, Approval=toggle_Approved.Value), ID, Descending)

     

    That is not working, although I may be missing your explanation.  Things do tend to go over my head....

  • mdevaney Profile Picture
    29,993 Moderator on at

    @csheets 

    Yes, that looks fine.  However, the datasource you are using and the data type of the column (if SharePoint) will affect the outcome here.  Please tell me what your datasource is and what column type Approval is (if SharePoint).

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • csheets Profile Picture
    74 on at

    @mdevaney 

    Datasource is a list called "Projects" and the "Approval" field is a Yes/No field.

  • mdevaney Profile Picture
    29,993 Moderator on at

    @csheets 

    Perfect.  That's what I hoped for.  I assume the code did not work?  It might be helpful to provide a screenshot of your app in the editor with any code showing in the formula bar.  A screenshot of your datasource would be great as well if it can be shared.

     

    Can you also try refreshing the datasource?  In PowerApps go to the left-side menu, select the Projects SharePoint list and click REFRESH.  Now try to run your app again.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • csheets Profile Picture
    74 on at

    @mdevaney 

    Tried everything suggested.  Doesn't look right to me, but then again, I don't know what right is, which is why I am here 🙂  Thanks for being so responsive!

    Request-TrueFalse.png

  • mdevaney Profile Picture
    29,993 Moderator on at

    @csheets 

    That error means you do not have any control named toggle_Approval in your app.  Can you please confirm?

  • csheets Profile Picture
    74 on at

    @mdevaney 

    That is correct.  I was going off of what you replied, which included toggle_Approval.  The fields name is Approval, so using just Approval.Value gets me "Invalid use of "."" for the period in between.  If I leave it at "Approval=True", no errors, but again, results are ones that = false.

    Form2.png

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @csheets 

    Based on the name of the toggle in your screenshot this is the code you should try.

    Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, Approval=DataCardValue14_1.Value), ID, Descending)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • csheets Profile Picture
    74 on at

    @mdevaney 

    That took the error away, but the stipulation right now is filtering on "Approval=DataCardValue14_1.Value", but I need to filter on that field, "Approval" equaling "true" or "false" correctly.

    Going off of all you assisted iwth so far, seems like this should work:

    Sort(Filter(Projects, Approver.Email=varCurrentUserEmail, DataCardValue14_1.Value=true), ID, Descending)

    If I set the value to True, I see no records.

    If I set the value to False, I see records that are both toggled on and off (true or false).

    Seems like a disconnect somehow, like it is not grabbing the true value of the record?

     

    My work day is over.  Pick back up on this in the AM on EST time!  Thanks for everything so far!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard