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

Count the number of Attachments in gallery

Hi
I would like to count the number of attachments in a gallery, I used CountRows, but can't get result. My code is CountRows(ThisItem.Attachments)

Actually I would like to have an icon to show the pictures of Attachments, if there's attachment, visible is true otherwise it's false.
I set the codes for Visible of the ViewPicture icon, the icon is in the gallery.
If(CountRows(ThisItem.Attachments)>0, true, false)
It doesn't work. Would you please tell what is wrong? Any solution?
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@Donglin 

What is meant by the ViewPicture Icon?  I might need a screenshot to understand better.

 

In general, you can check if a gallery item has attachments using this code.

 

!IsEmpty(ThisItem.Attachments)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
mdevaney
Super User III
Super User III

@Donglin 

What is meant by the ViewPicture Icon?  I might need a screenshot to understand better.

 

In general, you can check if a gallery item has attachments using this code.

 

!IsEmpty(ThisItem.Attachments)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

WarrenBelz
Super User III
Super User III

Hi @Donglin ,

CountRows(ThisItem.Attachments)

on a label in the gallery shows the number of attachments on each item. For a sum of the lot using AttNo as the label name and Gallery1 as the gallery would be

Sum(Gallery1.AllItems,AttNo)

As far as thumbnails, you certainly can display them from an individual attachment control with a collection - I posted this article on the subject recently, but I do not think you can do them all from a gallery.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

ViewPicture is the name of the icon.
Your codes work. And the CountRows also works. I had a mistake with my List in SharePoint, it's fixed now.
Thank you very much.

Hi WarrenBelz,
Thank you so much, your hits are also helpful to me.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (3,195)