Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I've been experimenting with building a US Election Dashboard but I'm struggling with the following data. Here's an example.
What I'd like to do is insert a column after that simply states "REP" or "DEM" based on who has the most votes. The difficulty for me is the DAX required to first:
- Sum up total votes in each state for each party
- Compare both values and display the greater
Any help would be appreciated
UPDATE:
Managed to get halfway there, summing up the totals for each state ( see below)
Sum of State = CALCULATE(SUM(president_county_candidate[votes]), ALLEXCEPT(president_county_candidate,president_county_candidate[state],president_county_candidate[party]))
Now I'm stuck on how to display REP or DEM based on which value is greater
Solved! Go to Solution.
HI @Anonymous,
You can use the following calculated table formula to output larger records from aggregated table records:
Summary table =
VAR summary =
SUMMARIZE ( Table, [state], [party], "t_votes", SUM ( Table[votes] ) )
RETURN
FILTER (
summary,
[t_votes]
= MAXX ( FILTER ( summary, [state] = EARLIER ( [state] ) ), [t_votes] )
)
Regards,
Xiaoxin Sheng
HI @Anonymous,
You can use the following calculated table formula to output larger records from aggregated table records:
Summary table =
VAR summary =
SUMMARIZE ( Table, [state], [party], "t_votes", SUM ( Table[votes] ) )
RETURN
FILTER (
summary,
[t_votes]
= MAXX ( FILTER ( summary, [state] = EARLIER ( [state] ) ), [t_votes] )
)
Regards,
Xiaoxin Sheng
User | Count |
---|---|
128 | |
108 | |
100 | |
64 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |