cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Community Support
Community Support

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
Anonymous
Not applicable

@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

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

Anonymous
Not applicable

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

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

Thks It worked for me 😉

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,444)