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

Top 3 Users

Hi everyone,

 

I'm trying to build a podium with the top 3 users, ranked by points.

Miguel36_0-1645552487913.png

Label 1 "Name 1" should have DAX that only calls the top 1 user. (same for the Label "Name 2" and Label "Name 3". To do this, it should do the sum of all the points for that user:

Sum(Filter('Item Details',UserEmail = ThisItem.'User Email'), ItemPoints.Value)
This is the code used inside the Gallery where I have the sum of all the points for each user. However I want to filter the timesheet to sum the points of each user and then just show the top1 in a label, the top2 in another label and the 3rd best user in the 3rd label.
Hope someone can help, Thank you 🙂

3 REPLIES 3
TheRobRush
Super User
Super User

I am assuming the list you are using has a new row for each person for each point so you may have same employee in there 10 times etc?

 

If that is the case I have put the following on a button in a powerapps and had it comb a sharepoint list of mine that has multiple rows for each employee etc. It then groups these by employee, and sorts those in descending order, and ranks them 1 - however high it needs to go. you could do something liek this and then filter your gallery to where their placement is 3 or lower etc.

 

ClearCollect(CountRows,{Value:1});
Clear(GroupUs);
ForAll(
    Sort(GroupBy(CoachingCurrent,"Title","Employees"),CountRows(ThisRecord.Employees),Descending),
    Collect(GroupUs,{Employee:ThisRecord.Title,Count:CountRows(ThisRecord.Employees),Placement:CountRows(CountRows)});
    Collect(CountRows,{Value:1}))

 

In the above CoachingCurrent is my list and "Title" is the original column containing each employees name

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!
rubin_boer
Super User
Super User

hi @Miguel36 

 

1. you need to group the data 

2. add a column for the scores

3. sort the scores

4. retrieve the first three scores

 

assuming your data contains "user", "score" or something similar

ClearCollect(
    _data,
    SortByColumns(
        AddColumns(
            GroupBy(
                //this is my datasource
                ForAll(
                    Sequence(110),
                    {
                        user: "User " & Mod(
                            Value,
                           6
                        ),
                        score: RandBetween(
                            30,
                            90
                        )
                    }
                )
                //end of data source - thi spart will be replaced by your datasource
,
                "user",
                "Users"
            ),
            "Score",
            Sum(
                Users,
                score
            )
        ),
        "Score",
        Descending
    )
);
UpdateContext(
    {
        first: First(_data).user,
        second: Last(
            FirstN(
                _data,
                2
            )
        ).user,
        third: Last(
            FirstN(
                _data,
                3
            )
        ).user
    }
)

Result

Peek 2022-02-22 20-54.gif

rubin_boer_0-1645555961782.png

 

Hope it helps ,

R

 

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.

I'm going to try to provide you with all the information:
This is the 'Item Details' Timesheet. I want to sum the points for each single user. So for example, me, as Miguel, would have 28 points. However in this timesheet, other user records also appear. If another user enters the app and adds a record, he gains points. But these should be sum only for this user.
Miguel36_0-1645556080572.png
My other timesheet is this one ('User Details'):

Miguel36_1-1645556293196.png
I currently have this scoreboard: However, this gallery is filtering by 'User Details'. The Number of records and the number of points were added.

Miguel36_2-1645556440034.png

Miguel36_3-1645556525296.png

Miguel36_4-1645556556776.png
The total number of records and the number of points are inside the gallery (as you can see by the "ThisItem." part of the functions, meaning that the gallery generates the values for the other users, as you can see in the 2nd pic of this post.
Miguel36_5-1645556598542.png


Don't know if it's possible to do the podium without collecting the number of points. The idea would be to "grab" the points from this gallery, and sorting them to the podium (for each label in the podium, 1st, 2nd and 3rd), but I don't think that is possible, since the values are not stored in a collection or timesheet. In the case I am obligated to "grab" the total points to a collection or timesheet, what would be the best way?

 

 Thank you 🙂

 

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,082)