cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anna2109
Helper I
Helper I

Count rows in SP list based on item selected in dropdown list

Hi all,

 

I have built an app where I need to add a function which will count the number of rows hosted in SharePoint list based on a selected item from a dropdown list.

 

If for example the dropdown list has as options: 

Apple

Orange

Pear

Strawberry

 

When the user selects Apple then a function to count all the rows in Sharepoint List which have apple as selected items.

 

Could you please advice?

 

Many Thanks,

 

Anna

2 ACCEPTED SOLUTIONS

Accepted Solutions
prajyot
Resolver III
Resolver III

 

Hello,

For test purpose you can add the label on the form and assign the Text property value to
CountIf( SPList,Title=dropdownlist.selectedText) , this will show the no. of count of selectedText inside the dropdownlist.


Hope it helps.

Thanks,
Prajyot M

View solution in original post

v-xida-msft
Community Support
Community Support

Hi @anna2109 ,

Which type column do you use to store the Dropdown selected option in your SP List? Text type column or Single text column?

Do you want to count the filtered records based on the selected option within the Dropdown box?

 

1. if you use Single text column to store the Dropdown selected option:

Please take a try with the following formula (add a Label within your app, set the Text property to following😞

 

CountRows(
                   Filter('YourSPList', FilteredColumn = Dropdown1.Selected.Value)
)

 

 

2. If you use Choice type column to store the Dropdown selected option:

Please take a try with the following formula:

CountRows(
           Filter('YourSPList', FilteredColumn.Value = Dropdown1.Selected.Value)
)

If you have enabled "Allow multiple selections" option for the Choice type column, please modify above formula as below:

 

CountRows(
           Filter('YourSPList', Dropdown1.Selected.Value in Concat(FilteredColumn, Value & ";"))
)

 

In addition, if you could select multiple options within your Dropdown box (the Dropdown box may be a ComboBox control), please consider modify above formula as below:

CountRows(
           Filter('YourSPList', Concat(ComboBox1.SelectedItems, Value & ";") in Concat(FilteredColumn, Value & ";"))
)

Note: The FilteredColumn represents the column in your SP List to store Dropdown selected option.

 

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

3 REPLIES 3
mdevaney
Super User
Super User

@anna2109 

I wrote something here but noticed the response of @prajyot was better.  Suggest you try their example.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

prajyot
Resolver III
Resolver III

 

Hello,

For test purpose you can add the label on the form and assign the Text property value to
CountIf( SPList,Title=dropdownlist.selectedText) , this will show the no. of count of selectedText inside the dropdownlist.


Hope it helps.

Thanks,
Prajyot M

v-xida-msft
Community Support
Community Support

Hi @anna2109 ,

Which type column do you use to store the Dropdown selected option in your SP List? Text type column or Single text column?

Do you want to count the filtered records based on the selected option within the Dropdown box?

 

1. if you use Single text column to store the Dropdown selected option:

Please take a try with the following formula (add a Label within your app, set the Text property to following😞

 

CountRows(
                   Filter('YourSPList', FilteredColumn = Dropdown1.Selected.Value)
)

 

 

2. If you use Choice type column to store the Dropdown selected option:

Please take a try with the following formula:

CountRows(
           Filter('YourSPList', FilteredColumn.Value = Dropdown1.Selected.Value)
)

If you have enabled "Allow multiple selections" option for the Choice type column, please modify above formula as below:

 

CountRows(
           Filter('YourSPList', Dropdown1.Selected.Value in Concat(FilteredColumn, Value & ";"))
)

 

In addition, if you could select multiple options within your Dropdown box (the Dropdown box may be a ComboBox control), please consider modify above formula as below:

CountRows(
           Filter('YourSPList', Concat(ComboBox1.SelectedItems, Value & ";") in Concat(FilteredColumn, Value & ";"))
)

Note: The FilteredColumn represents the column in your SP List to store Dropdown selected option.

 

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
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 (3,665)