cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Keyvan
Frequent Visitor

Filter SharePoint Document Content

Hello All,

I am trying to creat a PowerApps for filtering document library based on the file extension , 

My function not working on Checkbox and can not filter documents based on files extenstion.

Any advise, Please.

extension.png 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Keyvan ,

Could you please share a bit more about your scenario?

Do you want to filter your SP Library records based on specific file extension name (which is related to Checkbox)?

 

Based on the formula you provided, I think you have something misunderstanding with the Filter function in PowerApps. When you use Filter function to filter records in a data source, you should specify the column from the data source as Filter column to compare with a specific value.

On your side, the extension.Text is from the Gallery itself rather than the Documents data source. Please consider modify your formula as below:

Filter(
       Documents,
       Last(Split('File name with extension', ".")).Result = "docx"
)

 

In addition, you could not do the Filter operation in the Checkbox, then want the filtered result to be displayed within the Gallery (Is it not supported in PowerApps).

Please consider set the Items property of the Gallery to following formula:

Filter(
       Documents,
       If(
          WordCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "docx",
          true
       ),
       If(
          ExcelCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "xlsx",
          true
       )
)

Note: I assume that you check only one checkbox each time in your app.

 

If you also want to check two Checkbox controls at same time, please modify above formula as below:

If(
   WordCheckbox.Value && ExcelCheckbox.Value,
   Filter(Documents, Last(Split('File name with extension',".")).Result = "docx" || Last(Split('File name with extension',".")).Result = "xlsx"),
   Filter(
       Documents,
       If(
          WordCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "docx",
          true
       ),
       If(
          ExcelCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "xlsx",
          true
       )
   )
)

Please consider take a try with above solution, 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

4 REPLIES 4

@Keyvan 

 

Checkbox Value is True or False

 

Do something like this instead

 

 

If(Checkbox1.Value,Filter(Documents, extension.Text="docx"),If(Checkbox2.Value,Filter(Documents, extension.Text="xlsx"),false  ) )

 

 

You may need to substitute "false" with something else above - such as a statement that shows everything without filters.

 

Does this help?

@Keyvan 

 

Also for checking for both boxes checked scenario OR just one checked try this:

 

If(Checkbox1.Value && Checkbox2.Value,Filter(Documents, extension.Text="docx" || extension.Text="xlsx"), If(Checkbox1.Value,Filter(Documents, extension.Text="docx"),If(Checkbox2.Value,Filter(Documents, extension.Text="xlsx"),false  ) ) )

 

 

Thank you @poweractivate  but it is not working yet.

I think my filter has a issue. 

I'm getting extension value by this : Last(Split(ThisItem.'File name with extension',".")).Result 

But apparently for some reason extension.Text="docx" not working.

v-xida-msft
Community Support
Community Support

Hi @Keyvan ,

Could you please share a bit more about your scenario?

Do you want to filter your SP Library records based on specific file extension name (which is related to Checkbox)?

 

Based on the formula you provided, I think you have something misunderstanding with the Filter function in PowerApps. When you use Filter function to filter records in a data source, you should specify the column from the data source as Filter column to compare with a specific value.

On your side, the extension.Text is from the Gallery itself rather than the Documents data source. Please consider modify your formula as below:

Filter(
       Documents,
       Last(Split('File name with extension', ".")).Result = "docx"
)

 

In addition, you could not do the Filter operation in the Checkbox, then want the filtered result to be displayed within the Gallery (Is it not supported in PowerApps).

Please consider set the Items property of the Gallery to following formula:

Filter(
       Documents,
       If(
          WordCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "docx",
          true
       ),
       If(
          ExcelCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "xlsx",
          true
       )
)

Note: I assume that you check only one checkbox each time in your app.

 

If you also want to check two Checkbox controls at same time, please modify above formula as below:

If(
   WordCheckbox.Value && ExcelCheckbox.Value,
   Filter(Documents, Last(Split('File name with extension',".")).Result = "docx" || Last(Split('File name with extension',".")).Result = "xlsx"),
   Filter(
       Documents,
       If(
          WordCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "docx",
          true
       ),
       If(
          ExcelCheckbox.Value,
          Last(Split('File name with extension',".")).Result = "xlsx",
          true
       )
   )
)

Please consider take a try with above solution, 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.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,314)