Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
prpranav
Contributor II
Contributor II

Calculate Winning Party for every county in state for election

Hey everyone!

I'm working with state voter data, and I'm trying to create a chart with the winning party on each county . I have all the data organized in one central table.

The data table lists number of votes the candidate won in each precinct (subset of county).  A preview of the data table is attached below. 

As a measure, I tried :

FirstSortedValue( [Party], -aggr( sum([Candidate Votes]), [Candidate]))

but it returns only the party that won the entire election, not each county (a picture is attached below).

I believe the firstsortedvalue() is adding up all the votes in all counties and only returning one value for the winning party, but I'm not sure how to solve it. Any help would be appreciated. 

Thank you!

2 Replies
Lisa_P
Employee
Employee

Same as my other answer:

FirstSortedValue( [Party], -aggr( sum([Candidate Votes]), [Candidate], Party))

prpranav
Contributor II
Contributor II
Author

This is still resulting the same result 😞

Is there another way to make the calculation?