cancel
Showing results for
Did you mean:
Regular Visitor

## Count items in multiple columns

I'm building an app for keeping track of upkeep.

There will be 8 columns that can have the value of 1, 2, 3, or 4.

I'd like to filter, sort and count the number of a certain value in all 8 columns.

For example:

there may be 4 rows who all have 1 adress linking them lets call it "adress x" .

They are then grouped by the adress linking them. Then I'd like to find all rows that have one or multiple "4"s in the 8 columns. Next I'd like to count the number of "4"s in the group "adress x". Finally I want to sort a list of multiple adress-groups by how many "4"s were found at that adress.

Is it possible? I haven't found what function to even start finding value x in multiple columns and rows.

8 REPLIES 8
Solution Sage

If you're always looking for 4s, the simplest thing to do would be to add a calculated column to your data source that counts the number of fours on the row. If you had that, you could simply filter your gallery in power apps for rows where that value was > 0.

If that's not possible, you could filter the gallery for rows that had a four in any position, something like:

Filter(NumberList, Num1=4 || Num2=4 || Num3 = 4)

If you needed to know how many columns had a 4, you could add a calculated column to the table:

Or, use a variable so that you can look for other numbers besides four, and combine the two into one expression to use for the gallery:

``````AddColumns(
Filter(
NumberList,
Num1 = varNum || Num2 = varNum || Num3 = varNum
),
"NumberCount",
If(
Num1 = varNum,
1,
0
) + If(
Num2 = varNum,
1,
0
) + If(
Num3 = varNum,
1,
0
)
)``````

Regular Visitor

Thank you for your response Mike2500.

In your second paragraf, I'm guessing that "NumberList" is my own table, correct?

It seems like I would have access to inputting a formula column into my datasource. The interface is unguided however and I am unfamiliar with PowerFX. Would you know how the code would look to calculate all "x" in column "a", "b", "c"... etc.?

Solution Sage

Yes, NumberList is the underlying table or sharepoint list.

What is your data source?  Are you using SharePoint, DataVerse, other?

Regular Visitor

I'm using Dataverse within the PowerApps for Teams enviroment

Solution Sage

Ok, so the formula column you can add uses PowerFX, which is really the language used by power apps. So if your table has fields like num1, num2, etc., you can add the following as a formula:

If(num1=4,1,0+ If(num2=4,1,0) ...
Regular Visitor

Trying it, but keep getting an error that it was not possible to create or update the column. Might be a limitation or I'm doing something wrong...

Regular Visitor

Yep,

It's a limitation on dataverse for teams, cant use the function column.

I'll give the other method a go.

Thank you for your help and patience.

Regular Visitor

I did the in App version, but I'm having some trouble getting in the "groupby" function.

I've attached photos. The output is one line per "space" seen by the numbered bold labels. (eg. 101, 3 etc). I want to group them by the adress (eg. Repslag..., Evagat...). But when I try to nest the groupby function I can't seen to find where to put it.

Announcements

#### December 2023 User Group Update: Welcoming New Groups and Upcoming Events

A new month means it's time to celebrate and welcome the new user groups that have joined our community. We are excited to announce that we have more than 8 New Groups, which is no surprise after the amazing Microsoft Power Platform Conference. This month, we are breaking them out by the different community categories. If your group is listed here, give this post a kudo so we can celebrate with you! Don't forget to take a look at the many events happening near you or virtually! It's a great time of year to connect and engage with User Groups both locally and online.   Please Welcome Our NEW User Groups   Power Platform: PowerIT User Group: Nottingham Power Platform User Group: Bergen Power Platform User Group: Danmark Nashville Power Platform User Group Microsoft Ambassador Program y Mujer Latina Technolochicas NCWIT Community Copilot Studio:  Copilot User Group Italia Dynamics365: Dynamics User Group AdriaticDynamic 365 Azerbaijan   December User Group Events   01 Dec 2023 Aprendiendo Desarrollo web, creando mi primer power app y power page. 01 Dec 2023 Q4 Hybrid Philadelphia Dynamics 365 & Power Platform User Group Meeting05 Dec 2023APAC Dynamics 365 FastTrack Bootcamp - BI and Analytics07 Dec 2023Bay Area Power Platform Meetup: Learn, Share, and Connect07 Dec 2023Indiana D365/AX December User Group Meeting07 Dec 2023Dynamics User Group Meeting: Houston09 Dec 2023 December '23 - NEW Power Apps User Group Meeting - Online 12 Dec 2023December Cleveland Power Platform User Group Meeting12 Dec 2023 RW2 Data Stewardship Open Forum Discussion 13 Dec 2023  Black Country Power Platform User Group - December 2023 - West Midlands