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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Yew-Slaston
New Member

RANKX as measure with variable table

Dear community. What I'm doing wrong?

I get for each customer rank 1.

The idea is to calculate dynamic rank in a table which is a variable, depending on current filter context.

 

DynRank =
VAR Revenue = sum(tbSales[sales])
VAR tbTemp=
filter(SUMMARIZE(tbSales;tbSales[customers];"Revenue";sum(tbSales[sales]));[Revenue]>0)
VAR result = RANKX(all(tbTemp);[Revenue];;ASC)
Return
result

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @Yew-Slaston

 

You can create virtual table 'filter_table' based on the filter.

Then try measure as:

= RANKX(
       'filter_table',
       Calculate(
            sum(tbSales[sales]),
            ALL('tbSales')
       )
)

If the issue remains unresolved, please provide the pbix file after removing sensitive information.

 

Best Regards,
Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @Yew-Slaston

 

You can create virtual table 'filter_table' based on the filter.

Then try measure as:

= RANKX(
       'filter_table',
       Calculate(
            sum(tbSales[sales]),
            ALL('tbSales')
       )
)

If the issue remains unresolved, please provide the pbix file after removing sensitive information.

 

Best Regards,
Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

Jihwan_Kim
Super User
Super User

Hi, @Yew-Slaston 

Please try something like the below.

 

DynRank =
RANKX (
FILTER (
SUMMARIZE (
ALL ( tbSales ),
tbSales[customers],
"Revenue", SUM ( tbSales[sales] )
),
[Revenue] > 0
),
CALCULATE ( SUM ( tbSales[sales] ) ),
,
ASC
)

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

thank you, your measure works just for dimension customers. However, what I'm trying to achieve is to get the rankings for whatever row cotext I have on my worksheet. As soon as I change the context filter to customer group, I end up with 1 for every customer group. So, my thought is to make a virtual table depending of filter contect on the worksheet and then derive the rank based on current filter context. So that no matter what dimension and filter are on the sheet, I always get the correct ranking

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.