The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello Dear Community,
I've got a dataset with only one table:
Here's a few row's example:
Every song has a genre and a popularity. I just want to create a visual showing the top 5 genres based on their average popularity.
It shouldn't be too hard to do, but I can't make it 😞
I can make it adding filters in a bar chart, but I'd like to know how to do it with DAX:
Could you please give me a hand?
Thank you!
Solved! Go to Solution.
Hi @LuisNC
You can use a pattern like this:
1. First create an Average Popularity measure:
Average Popularity =
AVERAGE ( spotify_tracks[popularity] )
2. Next create the measure Average Popularity for Top 5 Genres:
Average Popularity for Top 5 Genres =
VAR N = 5
VAR TopGenres =
CALCULATETABLE (
TOPN (
N,
VALUES ( spotify_tracks[genre] ),
[Average Popularity]
),
ALLSELECTED ()
)
RETURN
CALCULATE (
[Average Popularity],
KEEPFILTERS ( TopGenres )
)
3. Place the measure Average Popularity for Top 5 Genres in the visual with genre on the axis.
Does this work for you?
Regards
Hi @LuisNC
You can use a pattern like this:
1. First create an Average Popularity measure:
Average Popularity =
AVERAGE ( spotify_tracks[popularity] )
2. Next create the measure Average Popularity for Top 5 Genres:
Average Popularity for Top 5 Genres =
VAR N = 5
VAR TopGenres =
CALCULATETABLE (
TOPN (
N,
VALUES ( spotify_tracks[genre] ),
[Average Popularity]
),
ALLSELECTED ()
)
RETURN
CALCULATE (
[Average Popularity],
KEEPFILTERS ( TopGenres )
)
3. Place the measure Average Popularity for Top 5 Genres in the visual with genre on the axis.
Does this work for you?
Regards
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
13 | |
13 | |
8 | |
8 |