Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
scaballerom
Helper I
Helper I

Top 10 Ranked Average

Hi all,


I have the following measure:

AvgDuration =
IF(SUM(Fact Jobs'[job_elapsed_min])>0 && ISBLANK([SUM(Fact Jobs'[job_elapsed_min]))=FALSE,AVERAGE('Fact Jobs'[job_elapsed_min]))
 
What I would like to do is rank the average duration of the processes by day. Then, obtain the average of the top 10 by each day, so I can make a line chart where Y is the avg duration, and X is the date.
 
I used:
RankAvgDuration =
RANKX (
        SUMMARIZE(ALLSELECTED('Fact Jobs'),'Fact Jobs'[job_name],"@AvgDuration",[AvgDuration]),
        [AvgDuration],
        , ,DENSE
    )
AvgTop10AvgDuration =
VAR AvgDuration =AVERAGEX(
    FILTER(SUMMARIZE(ALLSELECTED('Fact Jobs'),'Fact Jobs'[job_name],"@AvgDuration",[AvgDuration]),LEFT('Fact Jobs'[job_name],3)<>"ZZZ" && [RankAvgDuration]<=10),
    [@AvgDuration])
RETURN
AvgDuration
 
Sample Data:
Datejob_nameAvgDurationRankAvgDuration
10/01/2023 0:0023121,188
10/01/2023 0:002241,9914
10/01/2023 0:001985,9311
10/01/2023 0:001634,0515
10/01/2023 0:0021727,721
10/01/2023 0:001662,4112
10/01/2023 0:002893,539
10/01/2023 0:0033332,123
10/01/2023 0:0026189,46
10/01/2023 0:0030197,15
10/01/2023 0:0035432,852
10/01/2023 0:0026226,184
10/01/2023 0:003652,6713
10/01/2023 0:002688,6510
10/01/2023 0:0021179,337
11/01/2023 0:0023127,98
11/01/2023 0:0026409,682
11/01/2023 0:0016246,23
11/01/2023 0:001991,3610
11/01/2023 0:0019182,836
11/01/2023 0:002564,6914
11/01/2023 0:001765,2313
11/01/2023 0:001665,8912
11/01/2023 0:0030204,945
11/01/2023 0:002671,3411
11/01/2023 0:0026106,699
11/01/2023 0:0026233,344
11/01/2023 0:003653,7815
11/01/2023 0:00261672,821
11/01/2023 0:0021171,127
12/01/2023 0:0023121,896
12/01/2023 0:0019110,287
12/01/2023 0:002785,578
12/01/2023 0:0016589,891
12/01/2023 0:001633,0512
12/01/2023 0:0019188,774
12/01/2023 0:001731,7713
12/01/2023 0:0030202,933
12/01/2023 0:002672,999
12/01/2023 0:0026231,452
12/01/2023 0:003652,9411
12/01/2023 0:001863,7210
12/01/2023 0:001929,1315
12/01/2023 0:002230,0614
12/01/2023 0:0021180,525
13/01/2023 0:002220,1412
13/01/2023 0:0022270,853
13/01/2023 0:0019300,52
13/01/2023 0:001923,8610
13/01/2023 0:001713,7114
13/01/2023 0:002051,027
13/01/2023 0:001310,4715
13/01/2023 0:001795,694
13/01/2023 0:001414,4313
13/01/2023 0:002670,925
13/01/2023 0:003623,5311
13/01/2023 0:002926,089
13/01/2023 0:003652,86
13/01/2023 0:0026496,591
13/01/2023 0:002230,38
14/01/2023 0:00221101,321
14/01/2023 0:00180,0314
14/01/2023 0:00170,0413
14/01/2023 0:00160,186
14/01/2023 0:00150,048
14/01/2023 0:002627,972
14/01/2023 0:00262,615
14/01/2023 0:00265,993
14/01/2023 0:00262,634
14/01/2023 0:00260,177
14/01/2023 0:00180,049
14/01/2023 0:00180,0412
14/01/2023 0:00190,0315
14/01/2023 0:00200,0411
14/01/2023 0:00180,0410
15/01/2023 0:00217,1615
15/01/2023 0:00217,2914
15/01/2023 0:002313,911
15/01/2023 0:003264,46
15/01/2023 0:001627,879
15/01/2023 0:002018,9110
15/01/2023 0:00192182,211
15/01/2023 0:0030259,773
15/01/2023 0:002648,398
15/01/2023 0:0026179,744
15/01/2023 0:0026291,192
15/01/2023 0:00198,5613
15/01/2023 0:00199,3712
15/01/2023 0:001953,67
15/01/2023 0:0021174,455
16/01/2023 0:001626,113
16/01/2023 0:002024,6214
16/01/2023 0:0019307,322
16/01/2023 0:001927,212
16/01/2023 0:002041,599
16/01/2023 0:001766,757
16/01/2023 0:002622,8815
16/01/2023 0:0030212,484
16/01/2023 0:0026172,515
16/01/2023 0:0026240,423
16/01/2023 0:003652,128
16/01/2023 0:0026517,761
16/01/2023 0:001937,5110
16/01/2023 0:002229,711
16/01/2023 0:0021162,426
17/01/2023 0:0016343,922
17/01/2023 0:001635,4813
17/01/2023 0:0019315,573
17/01/2023 0:002047,8410
17/01/2023 0:001777,18
17/01/2023 0:002638,3112
17/01/2023 0:002642,6811
17/01/2023 0:0030200,025
17/01/2023 0:0026135,77
17/01/2023 0:00292815
17/01/2023 0:0026229,194
17/01/2023 0:003651,929
17/01/2023 0:0026570,751
17/01/2023 0:002228,5614
17/01/2023 0:0021192,326


Results I would like to obtain:

DateAvgTop10AvgDuration
10/01/2023 0:00258,806
11/01/2023 0:00344,688
12/01/2023 0:00184,801
13/01/2023 0:00141,861
14/01/2023 0:00114,099
15/01/2023 0:00330,053
16/01/2023 0:00181,088
17/01/2023 0:00216,433
 But I had no luck. Could someone help me out, please?
 
BR,
Sara
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Simple enough,

CNENFRNL_1-1674627567058.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Simple enough,

CNENFRNL_1-1674627567058.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@scaballerom , Try measure like

 

AverageX(keepfilters(topn(10, allselected('Fact Jobs'[AvgDuration]) ,_roll18, desc)),[AvgDuration])

 

or

 

 

calculate(AverageX(Values('Fact Jobs'[job_name]),[AvgDuration]),topn(10, allselected('Fact Jobs'[job_name]) ,[AvgDuration], desc))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.