Forum Discussion

PranjalSaxena's avatar
PranjalSaxena
New Member
2 years ago
Solved

Summarize on one column but select another column

I have a table as follows State Constituency Party Votes UP Noida SP 1000 UP Noida BJP 500 UP Noida INC 300 Gujarat Dholera SP 300 Gujarat Dholera BJP 2000 Guj...
  • rajendraongole1's avatar
    2 years ago

    Hi PranjalSaxena - Can you try the below calculated table in your model.

     

    WinnerParty =
    ADDCOLUMNS(
    SUMMARIZE(
    VotingResults,
    VotingResults[State],
    VotingResults[Constituency],
    "Max Votes", MAX(VotingResults[Votes])
    ),
    "Party",
    SELECTCOLUMNS(
    TOPN(
    1,
    FILTER(
    VotingResults,
    VotingResults[State] = EARLIER(VotingResults[State]) &&
    VotingResults[Constituency] = EARLIER(VotingResults[Constituency]) &&
    VotingResults[Votes] = EARLIER([Max Votes])
    ),
    VotingResults[Votes],
    DESC
    ),
    "Party", VotingResults[Party]
    )
    )

     

     

    It works please check.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!