Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Top and Bottom 5

Hi Everyone, 

 

I know its a very simple query but I don;t know why I am not gettting the correct results through filter.

 

Top5 Conditions

 

I have student ID along with distance travelled in a race. I want to filter the students who have covered more than 100m in race also want the top5 studeny by distance cover (higher the distance would be first) along with I have given a rating so for Top category rating should also be 5. So two conditions here for Top 5 - Distance is more than 100m, Rating would be 5.

 

Bottom 5 Condition

 

Rating would be 1 and distance covered would be more than 100m again. (I dont want to consider 0 in bottom rating)

 

Below is sample data

 

Student NumberDistance TravelledRating
9624571025
943307784
10024511602
12786531830
18892081623
19538001230
2139973515
846809320
9613601634
18554461515
7628471784
11486251231
20075061710
17539211780
2182136544
2018665550
19184561813
1312026533
5133571805
7825071075
2537671394
1486661972
1355566550
4153421442
681480904
1758550685
2174231413
15512681593
824355795
1281391815

 

I used a matrix where I have student name in first column, distance covered in second column, rating in third column. I filtered Rating as 5, Distance is greater than 100 but when I am filtering Top5 by distance it is showing blank.

 

Refer below snapshot

 

Kindly help.

 

Regards

Uphar

 

2 Replies

  • sturlaws's avatar
    sturlaws
    Icon for Resident Rockstar rankResident Rockstar

    Hi Anonymous 

     

    I am not able to reproduce your result with the sample data you have provided:

     

    Cheers,
    Sturla

    If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    I am able to produce the results by using the filter with Calculate

     

    Top 5 = CALCULATE(SUM(table[Distance]),FILTER(Table,table[Star Rating]=5)) and then used filter for more than 100km
     
    Thanks for your help.
     
    Regards
    Uphar