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
ovetteabejuela
Impactful Individual
Impactful Individual

Running MTD Totals per Employee

I want to do a running totals per employee but I'm not sure how to modify the code found here (by @Sean😞

Here's a simple table:

DateEmployeeDaily Total SalesMTD Sales
12/1/20161234553523 
12/2/20161234583572 
12/3/20161234518274 
12/4/20161234535805 
12/5/20161234553150 
12/6/20161234555140 
12/7/20161234588978 
12/8/20161234589324 
12/9/20161234526173 
12/10/20161234559700 
12/11/20161234582935 
12/12/20161234564540 
12/13/20161234599355 
12/14/20161234572151 
12/15/20161234564896 
12/16/20161234598963 
12/17/2016123456614 
12/18/20161234591711 
12/19/2016123451861 
12/20/20161234577544 
12/21/20161234579124 
12/22/20161234573478 
12/23/20161234513749 
12/24/20161234512037 
12/25/20161234576280 
12/26/20161234560449 
12/27/20161234592659 
12/28/20161234590484 
12/29/20161234523124 
12/30/20161234518919 
12/31/20161234510153 
12/1/20166789064334 
12/2/20166789023919 
12/3/20166789064124 
12/4/20166789016427 
12/5/20166789092575 
12/6/20166789093357 
12/7/20166789061797 
12/8/20166789098938 
12/9/20166789034467 
12/10/20166789090933 
12/11/20166789071387 
12/12/20166789033188 
12/13/20166789026750 
12/14/20166789036846 
12/15/20166789037498 
12/16/20166789026453 
12/17/20166789059530 
12/18/20166789072568 
12/19/20166789013294 
12/20/20166789038653 
12/21/20166789046135 
12/22/2016678906750 
12/23/20166789026677 
12/24/20166789097527 
12/25/20166789013703 
12/26/20166789054050 
12/27/20166789031225 
12/28/201667890811 
12/29/20166789041234 
12/30/20166789052108 
12/31/20166789089277 
2 ACCEPTED SOLUTIONS
Phil_Seamark
Employee
Employee

Hi @ovetteabejuela,

 

I have it working with the following measure.  It won't work if you try to add as a column.

 

MTD Sales = 
    CALCULATE(
            SUM(Employee[Daily Total Sales]) ,
            FILTER (
				ALL('Employee'[Date]) , 
				'Employee'[Date] <= MAX('Employee'[Date])
				)
				
				) 

You can see this working in the following Matrix visual

 

MTD.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

Sean
Community Champion
Community Champion

@ovetteabejuela

Here's the Measure that should do this Smiley Happy

 

Running Total MEASURE = 
CALCULATE (
    SUM ( 'Table'[Daily Total Sales] ),
    VALUES ( 'Table'[Employee] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)

Hope this helps!

 

Running Total per Employee.png

 

EDIT:

And if for some reason you want a COLUMN

Running Total COLUMN = 
CALCULATE (
    SUM ( 'Table'[Daily Total Sales] ),
    ALLEXCEPT('Table', 'Table'[Employee] ),
    'Table'[Date] <= EARLIER ( 'Table'[Date] )
)

View solution in original post

8 REPLIES 8
Sean
Community Champion
Community Champion

@ovetteabejuela

Here's the Measure that should do this Smiley Happy

 

Running Total MEASURE = 
CALCULATE (
    SUM ( 'Table'[Daily Total Sales] ),
    VALUES ( 'Table'[Employee] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)

Hope this helps!

 

Running Total per Employee.png

 

EDIT:

And if for some reason you want a COLUMN

Running Total COLUMN = 
CALCULATE (
    SUM ( 'Table'[Daily Total Sales] ),
    ALLEXCEPT('Table', 'Table'[Employee] ),
    'Table'[Date] <= EARLIER ( 'Table'[Date] )
)

Do you sleep @Sean ?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!


@Phil_Seamark wrote:

Do you sleep @Sean ?


 

 

LOL

Maybe he can answer tricky questions like this in his sleep 🙂


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_SeamarkAre you headed out for dinner?

 

Not on a Monday night. 🙂


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

ovetteabejuela
Impactful Individual
Impactful Individual

Okay, I can confirm that this is working and it's actually awesome! I added a little more filter so that it would reset the count in each month and I got this, I'll do a little more modification so that it would reset per month per year...

MTD Sales =
CALCULATE (
    SUM ( employee[Daily Total Sales] ),
    FILTER (
        ALL ( 'employee'[Date] ),
        'employee'[Date] <= MAX ( 'employee'[Date] )
            && MONTH ( 'employee'[Date] ) <= MONTH ( MAX ( 'employee'[Date] ) )
    )
)

 

Thanks @Sean & @Phil_Seamark

Phil_Seamark
Employee
Employee

Hi @ovetteabejuela,

 

I have it working with the following measure.  It won't work if you try to add as a column.

 

MTD Sales = 
    CALCULATE(
            SUM(Employee[Daily Total Sales]) ,
            FILTER (
				ALL('Employee'[Date]) , 
				'Employee'[Date] <= MAX('Employee'[Date])
				)
				
				) 

You can see this working in the following Matrix visual

 

MTD.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.