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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Running Total not correct when adding extra field

Hi!

 

I have been using this running total measure for several years now and never had any problem with the result, until now.

 

CALCULATE(SUM(fact[Quantity]),FILTER(ALLSELECTED(calendar[datetime]),calendar[datetime]<= MAX(calendar[datetime])))

As you can see everything works fine in the screenshot below.
 
RHBIP_1-1629274403161.png

 

But when I add the field 'Ordernumber' from the same table 'fact' the running total (cumulative) is not working anymore. I really do not understand why? I hope some of you do;) please enlighten me!



RHBIP_0-1629274349394.png

 

9 REPLIES 9
Anonymous
Not applicable

Hi @amitchandak 

This first measure with ALL does work, but I want to be able to filter on a Ordernumber and then it does not show the correct amount. The second measure with ALLSELECTED is almost correct!

 

The only thing is that the amount in yellow are correct, but only for the last row, very strange. 

RHBIP_3-1629356152514.png

 

 

 

Tanushree_Kapse
Impactful Individual
Impactful Individual

@Anonymous ,
 Try this measure:

RunningTotal =
CALCULATE (
SUM ( fact[Quantity] ),
FILTER ( ALL ( fact ), calendar[Datetime] <= MAX ( calendar[Datetime] ) );
VALUES ( fact[ordernumber )
)

 

 

I hope this helps!

Mark this as a solution if it answers your queation. Kudos are always appreciated.

Thanks! 

Anonymous
Not applicable

Hi @Tanushree_Kapse 

 

The measure not working, because the ALL includes the Fact and therefore I cannot filter the calendar. And could you maybe explain why I need tho add the Values part. I never had to use it before to get the correct outcome.

 

RunningTotal =
CALCULATE (
SUM ( fact[Quantity] ),
FILTER ( ALL ( fact ), calendar[Datetime] <= MAX ( calendar[Datetime] ) );
VALUES ( fact[ordernumber )
)

 

Hi @Anonymous ,

 

Sorry for the typo.

 

Try this:

RunningTotal =
CALCULATE (
SUM ( fact[Quantity] ),
FILTER ( ALL ( calendar), calendar[Datetime] <= MAX ( calendar[Datetime] ) );
VALUES ( fact[ordernumber )
)


Also here, the VALUES() puts the Ordernumber into the filter context of the CALCULATE()-statement. Otherwise you would have running totals on the dates, but it would be the same for all your Ordernumbers. 

 

Thanks

Anonymous
Not applicable

Hi @Tanushree_Kapse 

 

That is not working unfortunatly..

 

RHBIP_4-1629284142451.png

Even without ordernumber it is not working

RHBIP_3-1629284103265.png

 

When I remove the values part it does, but not with the ordernumber..

RHBIP_2-1629284056542.png

 

@amitchandak Can you please help on this?

@Tanushree_Kapse , @Anonymous , Based on what I got so far. So if take order number from fact and running total logic from the calendar then it running total within the order number. Value for *19 and *20 repeated for null value rows .

 

 

Try

 

RunningTotal =
CALCULATE (
SUM ( fact[Quantity] ),
FILTER ( ALL ( fact), fact[Datetime] <= MAX ( fact[Datetime] ) );
)

or

RunningTotal =
CALCULATE (
SUM ( fact[Quantity] ),
FILTER ( ALLSELECTED ( fact), fact[Datetime] <= MAX ( fact[Datetime] ) );
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak 

 

The second measure is almost correct, but as you can see the cumulative is not working correctly in some cases. See the yellow amounts where only the last of the three is correct.

 

RHBIP_0-1629358681226.png

 

Anonymous
Not applicable

@amitchandak @Tanushree_Kapse Any update on this problem?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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