web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Count duplicate values...
Power Apps
Unanswered

Count duplicate values across multiple column

(1) ShareShare
ReportReport
Posted on by 32

Hey everyone,

 

I got an issue with a Countif, i have a list with 4 columns :

 

Date / Service / APJ1 / APJ2 / APJ3 / APJ4

 

09-07-24 / Night / User1 / User 2 / User 6 / User9

07-07-24 / Day / User2 / User4 / User 9/ User 8

 

The AP column are choices with the same values, and i want to be able to count how many time a value appears in all the column for example on a combobox i select User2 i need to see : 2.

 

I tried with

 

CountIf(
    Gallery2.AllItems;
    'APJ 1 (08h-16h)'.Value = ComboboxCanvas2.Selected.Value ||
    'APJ 2 (08h-16h)'.Value = ComboboxCanvas2.Selected.Value ||
    'APJ 3 (16h-08h)'.Value = ComboboxCanvas2.Selected.Value ||
    'APJ 4 (16h-08h)'.Value = ComboboxCanvas2.Selected.Value
)
 
but it returns wrong numbers or none.
 
Thank you in advance for your help

 

 

Categories:
I have the same question (0)
  • Amol-Kavnekar Profile Picture
    125 on at

    Hi @FB5344 ,

     

    Set(varSelectedUser, ComboBox1.Selected.Value)


    Sum(
    ForAll(
    YourTableName,
    If(
    APJ1 = varSelectedUser, 1, 0) +
    If(APJ2 = varSelectedUser, 1, 0) +
    If(APJ3 = varSelectedUser, 1, 0) +
    If(APJ4 = varSelectedUser, 1, 0)
    ),
    Value
    )

     

    Regards

    Amol Kavnekar

    If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

     

  • CU13090816-0 Profile Picture
    32 on at

    Hi,

    I put this on a text field :

     

    Sum(
        ForAll(
            'Gardes Jud';
            If(
                'APJ 1 (08h-16h)'.Value = varSelectedUser;
                1;
                0
            ) + If(
                'APJ 2 (08h-16h)'.Value = varSelectedUser;
                1;
                0
            ) + If(
                'APJ 3 (16h-08h)'.Value = varSelectedUser;
                1;
                0
            ) + If(
                'APJ 4 (16h-08h)'.Value = varSelectedUser;
                1;
                0
            )
        );
        Value
    )
     
    but where to do i set the variable ?
     
    it's a basic screen with a gallery, a combobox & the text field that needs to return the sum of the selected user
     
    Thanks
  • Akshansh-Sharma Profile Picture
    298 Moderator on at

    Hi @FB5344 

     

    Can you put this code on the text property of your text field 

     

    With({Var_SelectedChoice:ComboBox1.selected.value},
    Sum(
    ForAll(
    Filter(YourTableName,OR(APJ1=Var_SelectedChoice,APJ2=Var_SelectedChoice,APJ3=Var_SelectedChoice,APJ4=Var_SelectedChoice)),
    If(
    APJ1 = varSelectedUser, 1, 0) + 
    If(APJ2 = varSelectedUser, 1, 0) + 
    If(APJ3 = varSelectedUser, 1, 0) + 
    If(APJ4 = varSelectedUser, 1, 0)
    ),
    Value
    ))

     

    I Changed the code slightly because we don't need to run the logic on thoses records where our selection is not present at all this will atleast trim down the records where we are running ForAll loop earlier it was on the whole table which can cause performance issues for the application

     

     

    --------------------------------------------------------------------------------------------------------------------

    Please click Accept as solution if my post helped you solve your issue. If the content was useful in other ways, please consider giving it Thumbs Up 😉

     

    LinkedIn- https://www.linkedin.com/in/akshansharma/

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard