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 / Remove items in sharep...
Power Apps
Answered

Remove items in sharepoint library that does not match

(0) ShareShare
ReportReport
Posted on by 152

Hello everyone,

 

I'm trying to expand an app, where I've come across a challenge.

I have a button that creates a new item in a sharepoint library, based on week numbers, and I only want the newest week to appear in the library for other use in the app.
But I dont know how to write the code I need for it to look up in the sharepoint library, and remove other elements that does not have the week number I just wrote. 

I'm looking for something like 

 

If(
 Lookup(
 Sharepoint library; Title != Textinput.Text);
#Where I want it to delete the items that does not equal the week number, and not do anything if it is the same

 

But I dont know how to write the code. 

Any help is much appreciated!

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @MortenBak ,

     

    If you want to remove items in the library based on conditions, you can try using the formula RemoveIf().

    My library:

    vxiaochenmsft_0-1666676063735.png

    Add a Button to the app and set the ‘OnSelect’ to the following formula:

    vxiaochenmsft_1-1666676081337.png

     

    RemoveIf(Test11,Not(WeekNum(Created)=WeekNum(Today())) Or Not(Year(Created)=Year(Today())))

     

    vxiaochenmsft_2-1666676104888.png

     

    After clicking, It removed files that are not this week.

     

    Best Regards,

    Wearsky

  • Verified answer
    MortenBak Profile Picture
    152 on at

    Hello Wearsky,

     

    I played with some other ways of doing it, and ended up using Last(Sharepointlist), and then creating a flow to delete files thats older than a month. I'm sure this would have done the trick as well, and I'll probably add this the next time I'm playing with PowerApps.

    Thank you for the response! 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard