cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

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
Highlighted
Community Support
Community Support

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
Highlighted
Resolver II
Resolver II

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

Highlighted
New Member

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

Highlighted
Resolver II
Resolver II

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.. 🙂

Highlighted
Community Support
Community Support

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

Highlighted
New Member

Re: Power Apps - Filtering Files by extension

Thks It worked for me 😉

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,705)