Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a question about the label of a KPI that I would like to make dynamic.
I have a team of 20 people (in my database as "player") that make a score every week (in DB: "points of the week"). I would like to create a display of the best score of the week and this score clearly changes every week and consequently also changes the name of the person who records it, which I would like to be displayed on the label.
How can I do this?
Thank you.
So to get the best player name you can try with this
=FirstSortedValue(Player, -Aggr(Sum(Score), Player))
and best score with just max(Score)
As you want to add players' age, you just modify the previously described formula to aggregate that too, so:
=FirstSortedValue(Player, -Aggr(Sum(Score), Player,Age))
Another solution would be to list all players with the best score if you aggregate just the score per player:
=concat(distinct aggr(if(sum(Score) = max(total aggr(sum(Score), Player)), Player), Player), ', ')
Can you help with the sample data and output please
Hi, maybe with something like this?:
=FirstSortedValue(player, -Aggr(Sum({<Week]{$(#=Max(Week))} [points of the week]), player))
But be careful if there will be two players with the same score.
Hi @salonicdk28 ,
Thanks for the answer.
For example:
Player : "Player1", "Player2", "Player3", "Player4"
Score of Week 1: 9, 2, 7, 10
For the first week, I want a KPI that shows: "Player 4" and his score (10).
The next week:
Score of week 2: 4, 5, 6, 2
Now the KPI is: "Player 3" and the score (best score of this week) is 6
Hi @justISO thanks for the answer. In my database I have only the column of the "Player" and a column with the "Score". Every week the "Score" change and i want to show the best score in my KPI
So to get the best player name you can try with this
=FirstSortedValue(Player, -Aggr(Sum(Score), Player))
and best score with just max(Score)
Thank you!
You can achieve the same in Script and use the variable in your Label which will serve your purpose
T1:
Load Player,
Sum(Score) as Scor
group by Player;
Load * inline
[
Player,Score
Player1,9
Player2,2
Player2,10
Player3,7
Player4,10
];
NoConcatenate
T2:
Load Player,
Scor
resident T1
Order by Scor;
Drop table T1;
Let VMaxplayer=Peek('Player','-1','T2');
Hi @justISO
As you say in the first answer I have a problem when two players have the same score. How can I solve this problem? Could I use other data? For each player I also have other data, for example age. Can I somehow enter age as the second parameter? With the same score I want the youngest to be displayed for example. is it possible to do this? Thank you
HI @demo1 - FirstSortedvalue will only give One resulting value , in case of Multiple resulting values you will get your Output as null.
Try to achieve the same using Script and use corresponding Fields in UI that will be lot simpler