Max in an Expression

Hello.

I have that aggregate in a screen preparation, and in the screen i want to show with an expreesion the name of player that have the max number of votes, how can i do this?

Hello Gonçalo,
One way to do that is to order by the NumberOfVotes descending and define the Max. Records = 1.

Best Regards

it can be a solution but i am using that aggregate in other things where i need all records, can i do it but without a limit on max records??


If you are using this aggregate to other things on the screen, and if the order can be the one I said above, you can just use the current record on the expression for the player with the higher number of votes, without a limitation for the max records.

May I ask what is the criteria when there's a draw on the number of votes? Because if the draw is a possible scenario, the solution I suggested, doesn't work.

Best Regards 

Hi Gonçalo,

You cannot, in general, easily do post-processing on the output of an Aggregate. So the best course of action is to create a seperate Aggregate (unless you can live with Paulo's suggestion).

Paulo Zacarias wrote:

If you are using this aggregate to other things on the screen, and if the order can be the one I said above, you can just use the current record on the expression for the player with the higher number of votes, without a limitation for the max records.

May I ask what is the criteria when there's a draw on the number of votes? Because if the draw is a possible scenario, the solution I suggested, doesn't work.

Best Regards 

the criteria is when max number of votes is a draw between two or more players, the admin of app choose one to win 


Gonçalo Sela wrote:

Paulo Zacarias wrote:

If you are using this aggregate to other things on the screen, and if the order can be the one I said above, you can just use the current record on the expression for the player with the higher number of votes, without a limitation for the max records.

May I ask what is the criteria when there's a draw on the number of votes? Because if the draw is a possible scenario, the solution I suggested, doesn't work.

Best Regards 

the criteria is when max number of votes is a draw between two or more players, the admin of app choose one to win 


you have some idea how can I use your suggestion even with this criteria  ?


Well, that doesn't sound very democratic :) but who am I to judge? Just kidding.

So, you can use the aggregate as I said, and order by descending on the number of votes, so in this case, you will have something like this:

Player Name | Number of Votes

Peter - 6

John - 6

Sam - 5

Mike - 4

If you say that in case of a draw, the admin decides who wins, just had some kind of selection widget between the eligible winners, Peter and John in the above example.