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
Anonymous
Not applicable

Running Total DAX exclude last years totals

Hello

 

I am running in to a bit of trouble on my Running Total formula. I want it to calculate the running total YTD but for some reason it is including last year (2017) in the sum for January 2018. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hard to tell exactly what's going on without seeing what type of visual you're trying to build. Can you include a screenshot of what fields you're putting on a visual? Also, are any slicers active? We need to see what the initial filter context is to help troubleshoot this further.

 

Also, if you're using a standard calendar (not a fiscal or 445 calendar), you can also try the built in time intelligence function:

 

 

[RunningTotal] =
CALCULATE ( SUM ( 'Labor Data'[Hrs] ), DATESYTD ( Calendar[Date] ) )

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

When you use ALL(Calendar[Date]), you remove the filter context on the current year.  So it returns every date that is less than the max date.

 

Try this:

RunningTotal =
CALCULATE (
    SUM ( 'Labor Data'[Hrs] ),
    FILTER (
        ALL ( Calendar[Date] ),
        Calendar[Date] <= MAX ( Calendar[Date] )
            && Calendar[Year] = MAX ( Calendar[Year] )
    )
)

Now it is keeping a filter context on the current year.  So no 2017 data will show up in the 2018 portion of the table.

Anonymous
Not applicable

Appreciate the response. That does make sense however, I receive an error saying "A single value for column 'Year' in table 'Calendar' cannot be determined. I believe it is due to my 'Year' field containing many values as it is dervied from the 'Date' field.

Anonymous
Not applicable

Hard to tell exactly what's going on without seeing what type of visual you're trying to build. Can you include a screenshot of what fields you're putting on a visual? Also, are any slicers active? We need to see what the initial filter context is to help troubleshoot this further.

 

Also, if you're using a standard calendar (not a fiscal or 445 calendar), you can also try the built in time intelligence function:

 

 

[RunningTotal] =
CALCULATE ( SUM ( 'Labor Data'[Hrs] ), DATESYTD ( Calendar[Date] ) )
Anonymous
Not applicable

Thank you kindly, I'll go with the time intelligence function.

Anonymous
Not applicable

Hello

 

I am running in to a bit of trouble on my Running Total formula. I want it to calculate the running total YTD but for some reason it is including last year (2017) in the sum for January 2018.

 

I have two tables (Calendar and Labor Data). The Calendar table includes Date, Year, MonthNumber, and MonthPrefix fields. Below is my formula. Any thoughts?

 

RunningTotal = CALCULATE(Sum('Labor Data'[Hrs]),FILTER(ALL(Calendar[Date]),Calendar[Date] <= Max(Calendar[Date])))

Hi,

 

To calculate the running total YTD, you could try with the expression

 

Running Total= Calculate(Sum(‘Labor Data’[Hrs]),DATESYTD(Calendar[Date],”31/12”))

 

You could refer to this example Calculating Sales Financial Year to Date in Power BI with DAX

 

A similar thread: DAX - Running Total YTD

 

Best Regards,

Henry

Hi,

 

Try this

 

=CALCULATE(Sum('Labor Data'[Hrs]),DATESYTD(Calendar[Date],"31/12"))

 

Drag Month from the Calendar table into your visual.  In the slicer/filter, select the year as 2018.  There should be a relationship from the Date column of the Lasor Data Table to the Date column of the Calendar Table.

 

Hope this helps.


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

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.