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 / Fetching items failed....
Power Apps
Answered

Fetching items failed. Possible invalid string in filter query

(0) ShareShare
ReportReport
Posted on by

I have been using the below code for over 12 months in a PowerApp and now without any changes to the app or the datasource it has stopped working.  I can't work it out but the common suggestion is using an As statement.  can someone please advise how to correct this code?

If(And(datesSelected, varType <> ""), Filter( 'Loan Equipment', varType = HardwareType, IsEmpty( Filter( 'Loan Dates', Ref = AssetID, Or( BEndDatePicker.SelectedDate <= EndDate && BStartDatePicker.SelectedDate >= StartDate, BEndDatePicker.SelectedDate >= EndDate && BStartDatePicker.SelectedDate <= StartDate, BStartDatePicker.SelectedDate >= StartDate && BStartDatePicker.SelectedDate <= EndDate, BEndDatePicker.SelectedDate <= EndDate && BEndDatePicker.SelectedDate >= StartDate ) ) ) ) )

Really appreciate your help 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Smudgers9 

    Your logic seems a little off on this formula, but a couple things...if this is an Items property, then you run the risk of leaving the Items empty - this is never a good thing and has bad results are run/play time.

     

    Consider the following formula instead:

    Filter( 'Loan Equipment', 
     HardwareType=varType &&
     
     datesSelected &&
     IsEmpty( 
     Filter('Loan Dates', 
     Ref = AssetID && 
     BEndDatePicker.SelectedDate > StartDate && 
     BStartDatePicker.SelectedDate < EndDate &&
     BEndDatePicker.SelectedDate <= EndDate &&
     BStartDatePicker.SelectedDate >= StartDate
     )
     ) 
    )

     

    I couldn't really figure out your date logic because it seemed that you restricted to before and after in one logic statement and then shifted to in-between in another one.  So, I assumed you wanted the dates in between the selected start and end.

     

    In the formula above, there is no need for the If statement you started out with.  Using that If would cause the Items to be blank if there was not a datesSelected (assuming variable) of true and varType to equal something.  The formula above incorporates that into the filter so the results are the same except that you are always returning a signature based table - even if with no rows.

     

    I hope this is helpful for you. 

     

  • Verified answer
    Smudgers9 Profile Picture
    on at

    Thanks for the response @RandyHayes but unfortunately I still get the same error when I run this formula.  Looking elsewhere online there is talk of an AS statement missing but I have no clue where this would go.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Smudgers9 

    Can you provide more details on why you expect an AS statement would help?

    Are you stating that either Ref or AssetID or both are used in both lists?

  • Smudgers9 Profile Picture
    on at

    I worked it out in the end.  It looks like some of the data sources naming conventions were a little strange from what I was provided so I have amended these along with changing how the filtering is run and this looks to have resolved the issue.  Thanks for the effort and advice though @RandyHayes I appreciate your time looking into this with me.

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard