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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Running total based on RANKX

Hi all,

- File link here -

I have a dynamic RANKX() measure that will recalculate based on a filter context (in this case - Month Year & Sales district)

I am trying to create a running total measure based on this RANKX().

It is partially working as you can see in the image below, but for some reason the running total starts on the second row and the final row does not equal the total of Quantity (t) column (13,707.79).

Table.JPG

Here are my measures :

- SumPrice = sum(Test[Price (€)])

- Price (€/t) = [SumPrice]*1000/[Quantity (t)]

- RankX = RANKX(ALLSELECTED(Division[Product code]),CALCULATE(([Price (€/t)])),,ASC,Dense)

- Running total sales =

VAR IndexRank = [RankX]

RETURN

CALCULATE (

SUM(Test[Qty (t)]),

FILTER ( ALL ( Division[Product code] ),

IndexRank

>= RANKX ( ALLSELECTED ( Division[Product code] ), [Price (€/t)],, ASC, Dense )

)

)

 

Sorry for code sample not inserted in a proper way but editing window won't let me put it.

Thanks for the help, 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

change 

 

FILTER ( ALL ( Division[Product code] ),

 

to 

 

FILTER ( ALLSELECTED ( Division[Product code] ),

 

Note that your totals are still wrong - you need to use HASONEVALUE  to handle that case separately.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks a lot @lbendlin, this is what I was missing.

Concerning the HASONEVALUE, I'm not familiar with it, do I need to create a new measure or include it within my measures?

 

Thanks,

You include it in the measure logic to distinguish between individual cells and the row total location of your visual.

lbendlin
Super User
Super User

change 

 

FILTER ( ALL ( Division[Product code] ),

 

to 

 

FILTER ( ALLSELECTED ( Division[Product code] ),

 

Note that your totals are still wrong - you need to use HASONEVALUE  to handle that case separately.

Helpful resources

Announcements
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!

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.

Top Solution Authors