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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PolarBear
Helper I
Helper I

Rankx by Group with filter

Good Morning,

I've tried googling this for a couple of days now but haven't found a solution that works for me..and my deadline is tomorrow 😕

 

I have a summarize table that I need to rank by category (category) and subcategory (YearWeekNum), only if the count is > 999.  I need the Rank to be a column, because I have to use it for another calculation (consecutive weeks in top 10).

 

CategoryAvg.CountYearWeekNumRankConsecutive Weeks in top 10
A4.210002020-412
A4.22222020-4 0
B3.820002020-422
C3.215002020-432
A3.628002020-332
B4.112002020-312
C3.918002020-322
A4.22222020-412

 

I've created a rank column using:

 

Rank =
Var WC = IF(Weekly_Stats[Count] > 999, 1)
Return
IF(WC <> BLANK(),
     RANKX(
         FILTER(
           Weekly_Stats,
           Weekly_Stats[YearWeekNum] = EARLIER(Weekly_Stats[YearWeekNum])
          ),
          Weekly_Stats[Weekly Average], , DESC, Dense
     )
)
 
The problem is that while it is leaving those with a count < 1000 blank in the column itself, it is still including them in the Rank #.. for example, Rank 3 below should actually be 1
CategoryAvg.CountYearWeekNumRank
A5.83822020-4 
A56912020-4 
A4.210002020-43

 

Thank you in advance for your help

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @PolarBear ,

 

Please update your formula as below.

ank = 
IF (
    Weekly_Stats[Count] > 999,
    RANKX (
        FILTER (
            Weekly_Stats,
            Weekly_Stats[YearWeekNum] = EARLIER ( Weekly_Stats[YearWeekNum] )
                && Weekly_Stats[Count] > 999
        ),
        Weekly_Stats[Avg.],
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Capture.PNG

 

Also attached the pbix.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @PolarBear ,

 

Please update your formula as below.

ank = 
IF (
    Weekly_Stats[Count] > 999,
    RANKX (
        FILTER (
            Weekly_Stats,
            Weekly_Stats[YearWeekNum] = EARLIER ( Weekly_Stats[YearWeekNum] )
                && Weekly_Stats[Count] > 999
        ),
        Weekly_Stats[Avg.],
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Capture.PNG

 

Also attached the pbix.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

@v-frfei-msft ,

 

This worked perfect! Thank you!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors