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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
AlbLS
Frequent Visitor

Running Total per Month from a Measure

Hello everyone,

I am new to the Power BI community. Thank you in advance for your help.

I have a problem with a cummulative calculation from a measure. This calculation works perfectly for the years, but it does not work for months. Let me explain:

I have two tables of human resources (entries and exits of employees):
- Entries
- Departures

Tables.JPG

 

 

 

 

 

 

 

 

 

 

 

I need to know the evolution of the workforce of the company, by year but also by month (to know the monthly evoulution in each year)
I mean, I need to create a chart with the total cumulate number of employees (running total)

To do this, I created several things:
- A date table
- Measures:
SumAnual Entries (sum of entries per year)
SumAnalDepartures (sum of departures per year)
DiffEntriesDepartures_YEAR (difference between the two preceding measures, that is the workforce of the company at the end of each year)
RunningTotalWorkforce_YEAR (cumulative effect after year)

 

For the year, it works perfectly.

The same thing for months, it does not work at all.

RunnngTotalYEAR.JPG

You think the problem comes from where? I tried many things but nothing worked.

Month.JPG

 

 

 

 

 

 

 

 

 

I leave you my power BI file.

https://drive.google.com/open?id=1iuSBrca3SS5JhMAYQGAowvKDamPjtl-d

I thank you so much if anyone can help me.

Best regards,

Alberto

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @AlbLS 

I've simplified this for you, hope its what you need.

# Entries = COUNTROWS( Entries ) 
# Departures = COUNTROWS( Departures )
# Difference = [# Entries] - [# Departures]
# Difference Running Total = 
IF( 
    NOT ISEMPTY( Departures ) || NOT ISEMPTY( Entries ),
    CALCULATE(
        [# Difference],
        FILTER(
            ALL( 'Date' ),
            'Date'[Date] <= MAX( 'Date'[Date] )
        )
    )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

Thank you very much for your answer and for your power bi file.

Unfortunately it does not solve my problem either, I already had the same result as you, but when the year changes, running totoal starts from scratch, and this is a mistake.

RunningTotalAshish.JPG

What I need is a graph like this:

when I'm going to filter for the year 2017, i will get this:

2017.JPG

and filter for the year 2018, this:

2018.JPG

I hope we can find the solution, for the moment I can not do it.

 

Thank you very much again.

 

Alberto

Hi,

Change the New Joinees YTD measure to:

Net joinees YTD = CALCULATE([Net joinees],DATESBETWEEN('Date'[Date],MINX(ALL('Date'),'Date'[Date]),MAX('Date'[Date])))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Ashish.

Your solution also works. It is different from that of Mariuzs, but it also works.

This could help other users!

Thank you so much!

Alberto

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Mariusz
Community Champion
Community Champion

Hi @AlbLS 

I've simplified this for you, hope its what you need.

# Entries = COUNTROWS( Entries ) 
# Departures = COUNTROWS( Departures )
# Difference = [# Entries] - [# Departures]
# Difference Running Total = 
IF( 
    NOT ISEMPTY( Departures ) || NOT ISEMPTY( Entries ),
    CALCULATE(
        [# Difference],
        FILTER(
            ALL( 'Date' ),
            'Date'[Date] <= MAX( 'Date'[Date] )
        )
    )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

AlbLS
Frequent Visitor

Hi Mariusz,


Thank you very much for your answer.

Unfortunately this does not solve my problem, as you can see in the following picture:

RunningTotalMariuzs.JPG

What I need is a graph like this:

when I'm going to filter for the year 2017, i will get this:

2017.JPG

and filter for the year 2018, this:

2018.JPG

 

I hope we can find the solution, for the moment I can not do it.

 

Thank you very much again.

 

Alberto

Mariusz
Community Champion
Community Champion

Hi @AlbLS 

Please see the file in the link.

https://drive.google.com/file/d/1ZDGVjlu4nNnweYCk6H9NUkWgX5Iscy2A/view?usp=sharing

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

AlbLS
Frequent Visitor

Thank you very much Mariuzs.

Your solution works perfectly, I really thank you. In addition, you have simplified the task because now I do not need different formulas for years and months, with your solution it works for both cases. It's perfect!

There is only one thing that I changed, I deleted from your formula the following part:
IF (
     NOT ISEMPTY (Departures) || NOT ISEMPTY (Entries)
)
Because it caused empty columns when there were no entries and no departures for a year or for a month. As we see here:

questionMariuzs.JPG

But i delete the IF statement, it works very well.

Thanks again.

Alberto

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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