cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MiguelSousaAMS
Level: Power Up

Power Apps - Filtering Files by extension

Hi,

 

I am building an application that goes trought some folders and then show some files (docsx or pdf).

Actually, I am trying to filter the files by All and PDF (All by default and a checkbox to change the filter).

 

 

If(
    idParentItem > 0 && isVisible <> true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = false,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem,
            EndsWith(Title,"pdf")
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = 0
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )
)

In the if statment where  idParentItem > 0 && isVisible = true && isPdf = true, is the validation that checks if is to show only pdf or not. I know it's working (it enters in the if statment) because if i remove the EndsWith(Title,"pdf") it shows the same information as the All filter. But if i leave it nothing appears.

 

I already tried to use:

"pdf" in Title

IsMatch(Title,"pdf", Contains)

 

Any possible solution for this?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Power Apps - Filtering Files by extension

Hi @MiguelSousaAMS ,

Could you please share a bit more about the "ProdDocsStructure" that you mentioned? Is it a SP Library?

 

If the "ProdDocsStructure" that you mentioned is a SP Library data source on your side, I think there is something wrong with your formula.

 

I have made a test on my side, please take a try with the following workaround:

Ser the Items property of the Gallery to following:

If(
    idParentItem > 0 && isVisible <> true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = false,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem,
            EndsWith('File name with extension', "pdf")   /* <-- Modify formula here */
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = 0
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )
)

Or

If(
    idParentItem > 0 && isVisible <> true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = false,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem,
            Last(Split('File name with extension', ".")).Result = "pdf"   /* <-- Modify formula here */
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = 0
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )
)

 

Above formula may cause a Delegation warning issue, if the amount of your SP Library records is not more than 2000, you could ignore this warning issue. You could change the "Data row limit for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App settings of your app, then you could process 2000 records locally at most.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
AndrewCarter
Level 8

Re: Power Apps - Filtering Files by extension

@MiguelSousaAMS,

 

Could you not use the FileNameWithExtension column and check that.. 

 

Last(Split(ThisItem.'File name with extension',".")).Result

You could even do the above in the collection of the data using AddColumn to create a filter value

AddColumns(source,"Extension",Last(Split('File name with extension',".").Result))

Andrew

MiguelSousaAMS
Level: Power Up

Re: Power Apps - Filtering Files by extension

It doesn't work because I nedd to filter this first: 

ProdDocsStructure,
Project = projectCode,
DefaultFolder = selectedFolder,
ParentItem = idParentItem

 

And then i need to catch every one that as ".pdf" in title

AndrewCarter
Level 8

Re: Power Apps - Filtering Files by extension

I am not too sure what the other logic checks are for as they do not affect the filter, but your collection might be created with

 

SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = If(idParentItem > 0, idParentItem, 0)
            If(isPDF, Upper(Last(Split('File name with extension',".")).Result) = "PDF", true)         
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )

otherwise I have nothing.. 🙂

Community Support Team
Community Support Team

Re: Power Apps - Filtering Files by extension

Hi @MiguelSousaAMS ,

Could you please share a bit more about the "ProdDocsStructure" that you mentioned? Is it a SP Library?

 

If the "ProdDocsStructure" that you mentioned is a SP Library data source on your side, I think there is something wrong with your formula.

 

I have made a test on my side, please take a try with the following workaround:

Ser the Items property of the Gallery to following:

If(
    idParentItem > 0 && isVisible <> true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = false,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem,
            EndsWith('File name with extension', "pdf")   /* <-- Modify formula here */
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = 0
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )
)

Or

If(
    idParentItem > 0 && isVisible <> true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = false,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    idParentItem > 0 && isVisible = true && isPdf = true,
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = idParentItem,
            Last(Split('File name with extension', ".")).Result = "pdf"   /* <-- Modify formula here */
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    ),
    SortByColumns(
        Filter(
            ProdDocsStructure,
            Project = projectCode,
            DefaultFolder = selectedFolder,
            ParentItem = 0
        ),
        "IsFolder",
        Descending,
        "Title",
        Ascending
    )
)

 

Above formula may cause a Delegation warning issue, if the amount of your SP Library records is not more than 2000, you could ignore this warning issue. You could change the "Data row limit for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App settings of your app, then you could process 2000 records locally at most.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

MiguelSousaAMS
Level: Power Up

Re: Power Apps - Filtering Files by extension

Thks It worked for me 😉

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,692)