Skip to content

Power Apps

COUNT The Unique Values In A Column

COUNT The Unique Values In A Column Input collection: myCities24 City Continent Country New York North America USA London Europe United Kingdom Kyoto Asia Ja...

Matthew Devaney
Published
Reading time
2 min read

Before you start

Is this guide for you?

Best entry point
Power Apps
Time investment
2 min read

Imported reference from Matthew Devaney's blog for learning purposes. Original: https://www.matthewdevaney.com/powerapps-collections-cookbook/count-the-unique-values-in-a-column/. Author: Matthew Devaney.

COUNT The Unique Values In A Column Input collection: myCities24 City Continent Country New York North America USA London Europe United Kingdom Kyoto Asia Japan Osaka Asia Japan Los Angeles North America USA Paris Europe France Birmingham Europe United Kingdom

Output value: mySolution24a (unique Country names) 4 Solution code: //Create a collection

ClearCollect(myCities24, { City : "New York" , Country : "USA" , Continent : "North America" }, { City : "London" , Country : "United Kingdom" , Continent : "Europe" }, { City : "Kyoto" , Country : "Japan" , Continent : "Asia" }, { City : "Osaka" , Country : "Japan" , Continent : "Asia" }, { City : "Los Angeles" , Country : "USA" , Continent : "North America" }, { City : "Paris" , Country : "France" , Continent : "Europe" }, { City : "Birmingham" , Country : "United Kingdom" , Continent : "Europe" } ); //Count unique values in column code

Set (mySolution24a,CountRows(Distinct(myCities24,Country))); Code language: JavaScript ( javascript )

Output value: mySolution2b (unique Continent names) 3 Solution code: //Create a collection

ClearCollect(myCities24, { City : "New York" , Country : "USA" , Continent : "North America" }, { City : "London" , Country : "United Kingdom" , Continent : "Europe" }, { City : "Kyoto" , Country : "Japan" , Continent : "Asia" }, { City : "Osaka" , Country : "Japan" , Continent : "Asia" }, { City : "Los Angeles" , Country : "USA" , Continent : "North America" }, { City : "Paris" , Country : "France" , Continent : "Europe" }, { City : "Birmingham" , Country : "United Kingdom" , Continent : "Europe" } ); //Count unique values in column code

Set (mySolution24b,CountRows(Distinct(myCities24,Continent))); Code language: JavaScript ( javascript )

Share this

Tagged

Power Apps

Have a Microsoft 365 topic idea?

Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.

Suggest a topic

Keep learning Microsoft 365

Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.

Continue learning

Next action

What to do next

Browse all tutorials →