We are having an election with rank choice voting. Voters can choose their 1st, 2nd, 3rd, 4th choice of candidates. There is only one winner. The winner is the first person to get the majority vote. At each round of calculation, we remove the lowest ranked candidate then look at the remaining options.
I have a table with three columns: VoterID, Candidate, Rank
I made a measure to count all the votes: Votes = Countrows(VoterTable)
To count the vote, we start by looking at everyone's 1st choice:
If no candidate gets the majority in the first round, then we remove the lowest ranked candidate and look at the 2nd choice FOR THOSE WHO VOTED for that, now removed, candidate. So I need to find the VoterID of those who voted for the last ranked candidate and look at their Second choice. Then I need to count the FIRST choice of all the successful candidate voters and the SECOND choice of all the people who's first pick has been eliminated.
Thank you very much for this. It is helpful but derives the wrong answer (my fault - because I did not provide you with the details about how the vote is counted).
After posting the question, I realized that I needed to learn the precise name and details of our particular voting system. We are using "Standard Preferential System" which basically, looks at the first choice of each voter but never looks at second or subsequent choices on any ballot unless a voter's first choice candidate has been eliminated from the race. I found an explanation of all the different ways of counting rank ballot systems in this link: https://www.aec.gov.au/About_AEC/AEC_Services/Industrial_Elections/voting.htm#four
Using Standard Preferential system with my data set, results in a win for Dolly Duck not Donald (strange but true).
I never did figure out a DAX formula for this because I am pretty weak with DAX, but I did manage to use Power Query to create the data sets to chart. This is NOT a real solution because I had to manually type in the names of each losing candidate in order to get my results (not worth figuring out how to do it properly as we are only running the vote one time and the polling company will give me this information - my mission was simply to chart it).
Here is a link to how I have depicted the results in PowerBI: