cancel
Showing results for
Did you mean:
Regular Visitor

## Rank based on a measure

I have marks from students who have completed some tests. I have created a measure which gives me the average of the students results.

`Scld Mark Ave =  AVERAGE(uncRedshift_Studentresults[Scld])`

I have slicers on the page which filter the Fileyear and Student_ID so I get an average Scaled mark for a particular student in a particular year. This works fine.

Now I would love to give a rank to each student eg Student_ID 1234 with an average scaled mark of 62.45 is ranked 78th out of the whole year group of 230 Year 9 students in 2018. In other words, I want to rank the average scaled mark for this student against the average scaled mark for everyone else in the Year Group for a particular year. I want to put this in a card eg "78 out of 230". Not sure at all how to go about doing this?

I have provided some data with students with scaled marks in their subjects by Year and YearLevel.

Any help would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Rank based on a measure

@dphillips add following measure for rank

```Rank =
RANKX(
FILTER(
ALL( Sheet1[FileYear], Sheet1[StudentYearLevel], Sheet1[StudentID] ),
Sheet1[FileYear] = MAX(Sheet1[FileYear]) &&
Sheet1[StudentYearLevel] = MAX( Sheet1[StudentYearLevel] )
),
[Average Marks], , ASC, Dense
)
```

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

6 REPLIES 6
Super User

## Re: Rank based on a measure

@dphillips add following measure for rank

```Rank =
RANKX(
FILTER(
ALL( Sheet1[FileYear], Sheet1[StudentYearLevel], Sheet1[StudentID] ),
Sheet1[FileYear] = MAX(Sheet1[FileYear]) &&
Sheet1[StudentYearLevel] = MAX( Sheet1[StudentYearLevel] )
),
[Average Marks], , ASC, Dense
)
```

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

Highlighted
Regular Visitor

## Re: Rank based on a measure

@parry2k  - Thanks for the info. I keep getting a rank of 1 for any student I select. Have looked at your measure and tested filters, and the aggregations used, substituted in actual values etc, but I still always get a rank of 1 no matter which student I select. Any thoughts about what I am doing wrong? This is my measure for getting the average scaled mark for a student.

`Average Marks = AVERAGE([ScldMark])`

I then have slicers on the page for Fileyear, StudentYearLevel and StudentID.

I want this to be displayed in a card on its own.

Perhaps the problem is that this needs to be in a table or matrix so it can rank against the other values in the visual. If that is the case, how can I get this to be a standalone rank in a card? (Just tested this theory in a table and found that your measure works great - everything correct  - thanks so much - but as I said - I want to try and create a kpi matrix which uses a card with just the rank for that one student)

Any thoughts?

Super User

## Re: Rank based on a measure

@dphillips it should work, let me double check with slicer you mentioned in your message.

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

Regular Visitor

## Re: Rank based on a measure

@parry2k - it does work great when in a table or matrix but my issue is I was trying to get this in a standalone card and create a sort of KPI for a student, rather than having a table with all  the students in it. Is this possible?

Thanks again for all your help.

Super User

## Re: Rank based on a measure

@dphillips are you ok to share pbix instead me recreate everything at my end. Remove any sensitive it contains.

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

Regular Visitor

## Re: Rank based on a measure

Hey @parry2k . Thanks so much for your help. I duplicated the page I was using, got rid of lots of slicers and filters to try and work out what was goin on and then started afresh on a new page and the card works properly on that page. Went back to the original page and, in the end, just got rid of the card and put a new card in, used the measure and all was fine. Again - thanks for all your help.