cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

How to generate TOP 5 based on Average and display in bar chart?

Hello Guys,

 

Below you see is a sample dataset. What I am trying to achieve is to generate TOP 5  for each attribute group by "Group ID". The TOP 5 values should be an average of the values that are taken into consideration. Hence, in our example, I would say that when a user selects Group-ID as 0, he should see  5 values as:

 

a. Wheat Production: 312 (Average of 400 and 224)

b. Maize: 205 (Average of 144 & 266)

c.  Rice: 100 (Average of 200 & 0)

d.  Flour: 87.5 (Average of 175 & 0)

e. <<Some other value>>

 

I treid using a rankX function in DAX. What i have written is mentioned as:

 

RANKX(ALL('table(2)'[Value]),CALCULATE(AVERAGE('table (2)'[Value])),,DESC)

I don't thik this working as it should. I am not sure what the formulae would be. Help needed!

Capture-1.PNG

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

You can try to use following measure to calculate group average and do ranking on it:

Top 5=
VAR summary =
    SUMMARIZE ( Table, [Group ID], [Attribute], "AVG", AVERAGE ( Table[Value] ) )
VAR rank =
    RANKX ( summary, [AVG], AVERAGE ( Table[Value] ),DESC, DENSE )
RETURN
    IF ( rank <= 5, "Y", "N" )

You can use it in visual level filter to filter 'Y' result to display top 5 records.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors