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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
paliman
Frequent Visitor

Running totals works fine only for the first month

Hello people.

 

I need some help calculating a running total based on a daily forecast.

 

So, here’s a screenshot of my model:


Relationships.PNG

 

As Forecasts are calculated on a monthly basis, I can´t set a relation to the calendar table. So, my measures are as follows:

 

Total Forecast =

    CALCULATE(

        SUM(Forecast[Total Sales]),

        TREATAS(VALUES('Calendar'[Month & Year]),Forecast[Month & Year]))

 

Days in Context = COUNTROWS('Calendar')
 
Days in Month =
      CALCULATE(
             COUNTROWS('Calendar'),
                      ALL('Calendar'), VALUES('Calendar'[Month & Year]))
 
Daily Forecast =
      IF(HASONEVALUE('Calendar'[Date]) || HASONEVALUE('Calendar'[Month & Year]),
           DIVIDE([Days in Context],[Days in Month],0) * [Total Forecast],
           [Total Forecast])
 
So far so good, Then I want to calculate a running total based on my daily forecast:
 
Daily Forecast running total in Date =
     CALCULATE(
         [Daily Forecast],
         FILTER(
             ALLSELECTED('Calendar'[Date]),
             ISONORAFTER('Calendar'[Date], MAX('Calendar'[Date]), DESC)))
 
And here's the result:
Result.PNG
 
No matter what time frame, it always works fine ONLY for the first month and then adds up the whole monthly amount for each day
 
What am I missing?
 
Many thanks in advance
 
Pablo.
 
Sample file:

 
2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @paliman ,

 

If you haven't resolved it and you still need help, can you please upload the sample file into OneDrive for Bussinees and share again with us?  Now, I can't download it without access from your link.

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@paliman , I think it would better if you create a daily forecast. and then use it.

Refer if this file :https://www.dropbox.com/s/fnq82ksdzk1lqs3/Target_allocation_daily.pbix?dl=0

 

Another option, do not split, check if that can work

https://www.youtube.com/watch?v=yPQ9UV37LOU

 

The reason it is not working, one measure is diving and distributing another one again aggregating that. Need to rework on the measures.

 

See any of the two approach can work.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.