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
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 233 members 4,457 guests
Please welcome our newest community members: