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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RH-BIP
Helper III
Helper III

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
RH-BIP
Helper III
Helper III

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

@RH-BIP ,
 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! 

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 @RH-BIP ,

 

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

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 , @RH-BIP , 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] ) );
)

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

 

@amitchandak @Tanushree_Kapse Any update on this problem?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors