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
Matjo
Advocate I
Advocate I

Total to date working the same way as TOTALYTD

Is there a formula that works like total year to date, but instead of year to date it sums everything until the date. 

I have tried to create a running sum by using DAX but it does not behave as I want. TOTALYTD does exactly what I want except I want it for all previous dates instead of this year.  

Here is an example FILE. For January 2017 I would like the running diff to be -100 for company A and 0 for B in February I would like it to be -200 for A and 100 for B




1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Matjo,

I download your file, and create a Calendar table using the formula by clicking "New Table" under Modeling on Home page.

Calendar = CALENDAR(MIN(Test[Date]),MAX(Test[Date]))


Create relationship between Calendar and Test table.

Then create a measure using the formula below.

running_diff =
CALCULATE (
    Test[diff],
    FILTER ( ALL ( Calendar ), Calendar[Date] <= MAX ( Calendar[Date] ) )
)


Please select the Test[Company] as rows, Calendar[Date] as column, you will get expected result as follows.

1.PNG
Best Regards,
Angelia


View solution in original post

2 REPLIES 2
v-huizhn-msft
Employee
Employee

Hi @Matjo,

I download your file, and create a Calendar table using the formula by clicking "New Table" under Modeling on Home page.

Calendar = CALENDAR(MIN(Test[Date]),MAX(Test[Date]))


Create relationship between Calendar and Test table.

Then create a measure using the formula below.

running_diff =
CALCULATE (
    Test[diff],
    FILTER ( ALL ( Calendar ), Calendar[Date] <= MAX ( Calendar[Date] ) )
)


Please select the Test[Company] as rows, Calendar[Date] as column, you will get expected result as follows.

1.PNG
Best Regards,
Angelia


Hi @v-huizhn-msft and thanks!

I got it to work in my big model now. I had been playing around with similar solutions but never got them correct and they were very slow. I then discovered that Power BI had created the crossfilter between my date dimension and one of the fact tables running both ways and when I made that single everything started working. 

Thanks for your time!

Best regards,
Mattias 

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.