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

Counting the Instances of a Sharepoint Object Name in Power Apps

Hope everyone is safe and well.

 

I am attempting to count the amount of times a specific Value appears within a column (multiple Values can be selected for each row), however, the data stored within the cells seems to be a link to another SharePoint table. When I try to filter for a particular Value within the column, I receive an Incompatible Type Error (Table, Text). Is there a method to overcome this?

 

Since the SharePoint tables belong to the company I work for, I am unable to share proper screenshots but attached is what the data looks like when displayed using a Data Table.

 

Values.png

 

 

 

 

 

 

 

 

 

 

Thank you so much.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @nep22 ,

I am not sure whether myself or @BCLS776 are on the right track here (his is the correct solution for a nested Table), but I suspect what you are showing in the example Data Table is a Multi-Choice field. If so, you can filter this on the data source forming the table - so if the Data Table was showing the table MySPList and the field displayed was MySPField and you were looking for how many times MyValueFound appeared, it would be something like

CountRows(
   Filter(
      MySPList,
      "MyValueFound" in MySPField.Value
    )
)

You will get a Delegation warning on this - if your data table was filtered by

Filter(
   MySPList,
   MyStatusField = "Current"
)

and this resulted in under 2,000 records (and your delegation limit is set to this), you could do this in a Delegable fashion with

With(
   {
      wList:
      Filter(
         MySPList,
         MyStatusField = "Current"
      )
   },
   CountRows(
      Filter(
         wList,
         "MyValueFound" in MySPField.Value
       )
   )
)

 

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.

View solution in original post

4 REPLIES 4
BCLS776
Super User
Super User

How about something like?:

CountRows(
    ForAll(myTable.Values As aRecord,
        ForAll(aRecord.Values As aItem,
            If(aItem = "SpecificValue", { Value: "Count one"})
        )
    )
)

You'll need to modify this code to suit your situation:

  • It assumes the embedded objects in your column are some sort of string
  • You'll have to provide a proper comparison value for "SpecificValue" 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
WarrenBelz
Super User
Super User

Hi @nep22 ,

I am not sure whether myself or @BCLS776 are on the right track here (his is the correct solution for a nested Table), but I suspect what you are showing in the example Data Table is a Multi-Choice field. If so, you can filter this on the data source forming the table - so if the Data Table was showing the table MySPList and the field displayed was MySPField and you were looking for how many times MyValueFound appeared, it would be something like

CountRows(
   Filter(
      MySPList,
      "MyValueFound" in MySPField.Value
    )
)

You will get a Delegation warning on this - if your data table was filtered by

Filter(
   MySPList,
   MyStatusField = "Current"
)

and this resulted in under 2,000 records (and your delegation limit is set to this), you could do this in a Delegable fashion with

With(
   {
      wList:
      Filter(
         MySPList,
         MyStatusField = "Current"
      )
   },
   CountRows(
      Filter(
         wList,
         "MyValueFound" in MySPField.Value
       )
   )
)

 

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.

Thank you so much! This was in fact an example of a Multi-Choice field.

Thank you so much for your reply!

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (2,679)