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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Data-Hound
New Member

Exclude TOPN() or top RANKX() from Matrix

Hi all,
I have tried this many ways and can't quite get it to work. I need to create a Matrix and exclude the top 25 states based on COUNT() of ID from the State table and the MAX() Year from the Date table. There is a 1:M relationship between the Date table and State Table. Sample tables look like:
State

StateIDCostDateYear
A1101/1/20222022
B2201/2/20222022
C3501/3/20222022
D451/4/20222022
A5201/1/20212021
B6401/2/20212021
C7601/3/20212021
A8202/1/20222022
A9301/1/20212021
A10401/1/20202020
B11401/1/20202020
B12202/1/20222022


Date

DateYear
1/1/20202020
1/2/20202020
1/3/20202020
1/4/20202020
1/1/20222022
1/2/20222022
1/3/20222022
1/4/20222022

 

The table without excluding the top 25 States and Max year Looks like this:

StateCOUNT_IDSUM_Cost
A530
B440
C150
D15

 

I need it to look like this:

StateCOUNT_IDSUM_COST
C150
D15

 

The table should respond to all filters that are applied. I have tried many different versions using RANKX() and TOPN(), but it never seems to work out. I think the problem is that TOPN() and RANKX() are calculating across all years and not the MaxYear (which is a measure) from the Date table.

 

Any help is appreciated.

Thank you

1 REPLY 1
FreemanZ
Super User
Super User

Hi @Data-Hound ,

 

Having problem making consistent understanding of the description and the sample data. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.