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 / Power Apps & filter Sh...
Power Apps
Suggested Answer

Power Apps & filter SharePoint list using condition (different list sources)

(2) ShareShare
ReportReport
Posted on by 9
Hello everyone, I'm experiencing some strange behavior with my filter query in Power Apps / SharePoint list.

Expressions:

With ({
    myTimeData;
    Filter(
        If(_historyYear = Year(Today());
            TimeHistory;
            TimeHistory    //planned: other SP list
        )
    };
    ....
)

With ({
    myTimeData;
    Filter(
        //If(_historyYear = Year(Today());
            TimeHistory;
           // TimeHistory    //planed: other SP list
        //)
        )
    };
    ...
)
 
The first expression returns no results.
When I comment out the If statement (expression 2), one record is found as expected.
How can I solve this problem? Currently, the same SharePoint list is being used as the data source for both cases. The plan is to move historical data to a separate location so that the SharePoint lists don't become too large.
no_result.jpg
result.jpg

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    3,748 on at
     
    Can you try this 
     
    Filter(
        myTimeData,
        Year(TimeHistory) = _historyYear
    )
     
    or
     
    Filter(
        myTimeData,
        Year(TimeHistory) = If(_historyYear = Year(Today()), Year(Today()), _historyYear)
    )
    Vishnu WR
     
    Please  Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like 
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    The problem is not the filter itself — it is the placement of the If() function inside Filter().
     
    Your current formula creates a query structure that SharePoint cannot reliably delegate or evaluate.
     
    The correct solution is:
    • Use If() to switch the datasource
    • Keep the filter condition simple
    • Use explicit Boolean comparison (TimeHistory = true)
    • Separate current and historical data sources as your dataset grows
    Try below:
    Filter(
        If(
            _historyYear = Year(Today());
            myCurrentTimeData;
            myHistoricalTimeData
        );
        TimeHistory = true
    )
     
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @KK-16061327-0,
     
    Apparently, the If statement inside the Filter is not returning a logical condition (true/false) but rather a table or record, which causes the filter to fail.
     
    If your intention is to filter myTimeData based on whether _historyYear equals the current year, you need to write a logical condition inside Filter.
     
    Filter(
        myTimeData,
        If(
            _historyYear = Year(Today()),
            true,       // If condition is true, include all records (no filter)
            TimeHistory = _historyYear  // Otherwise, filter where TimeHistory equals _historyYear
        )
    )
    
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Assisted by AI
    MM-13050633-0 Profile Picture
    10 on at
    You should return a proper boolean comparison from the If().

    Filter(
        myTimeData;
        If(
            _historyYear = Year(Today());
            TimeHistory = true;
            TimeHistory = true
        )
    )

    checkout more at https://www.qservicesit.com/custom-power-apps-development-use
  • KK-16061327-0 Profile Picture
    9 on at
    Please take a look at the screenshots to understand my problem. I'm not currently using different SharePoint lists. That's not the issue.
    The problem is the if statement itself.
    Image
    Image
     
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    The problem is that your If statement returns a column reference (TimeHistory) instead of a boolean condition. Filter expects each row to evaluate to true or false, but returning a column value confuses the delegation engine and SharePoint returns nothing.
     
    The fix depends on what TimeHistory actually is. From your formula it looks like TimeHistory is a boolean (yes/no) column:
    If that's the case:
    Filter(
        myTimeData,
        If(
            _historyYear = Year(Today()),
            TimeHistory,
            Not(TimeHistory)
        )
    )
    This returns current records (TimeHistory = true) when the selected year is the current year, and historical records (TimeHistory = false) for past years.
    If TimeHistory is actually a year number column:
    Filter(
        myTimeData,
        Year(TimeHistory) = _historyYear
    )
    The If wrapper is unnecessary here since you're filtering by year in both cases.
     
    Can you confirm what data type TimeHistory is? That will tell us which version to use.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Ram Prakash Duraisamy Profile Picture
    5,877 Super User 2026 Season 1 on at
     
    I think WITH Operation will help you to achieve the same easily
     
    With(
        {
            myTimeData:
            If(
                _historyYear = Year(Today()),
                Filter(TimeHistory, historyYear = _historyYear),
                Filter(TimeHistory, historyYear = _historyYear)
            )
        },
        myTimeData
    )
     
    Please mark as answer if my suggestion helps.
    Subscribe here for More Useful videos : https://www.youtube.com/@rampprakash3991

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard