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
NathanSaber
New Member

Sum to Date

I'm having trouble calculating the Sum to Date when selecting a month from a Slicer.

 

The result I'm expecting is per table below when I select Feb from the Month Slicer

CategoryMonthTo Date
A3080
B100135

 

I've tried the following DAX formula for my To Date Measure, however it is returning the same results as the Month column above.

To Date =

CALCULATE(SUM(Transactions[Amount]),FILTER(ALL(Transactions[Period]),Transactions[Period] <= MAX(Transactions[Period])))

 

The details of the tables are below. They are linked via the Period field in both Tables. One to Many relationship (One - Period Table, Many - Transactions Table)

 

Transactions

PeriodAmountCategory
120A
130B
420A
410A
45B
840B
830A
860B
915A
925B
1210A
1230A

 

Period

PeriodMonth
1Jul
2Aug
3Sep
4Oct
5Nov
6Dec
7Jan
8Feb
9Mar
10Apr
11May
12Jun
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@NathanSaber , In case you have date prefer Time Intelligence

 

In This case, the Assume period is joined to Transaction. Ideally, In such cases you need to have the time/period table separately and use that

To Date =
CALCULATE(SUM(Transactions[Amount]),FILTER(ALL(Period),Period[Period] <= MAX(Period[Period])))

 

In case you have a Date, refer

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

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

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @NathanSaber,

You can add a values function to your formula to simple group the rolling result based on the current category:

To Date =
CALCULATE (
    SUM ( Transactions[Amount] ),
    FILTER (
        ALLSELECTED ( Transactions[Period] ),
        Transactions[Period] <= MAX ( Transactions[Period] )
    ),
    VALUES ( Transactions[Category] )
)

DAX – The Many Faces of VALUES() 

BTW, I'd like to suggest you use allselected to replace all function if you want to keep original filter effects apply on your table:

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@NathanSaber , In case you have date prefer Time Intelligence

 

In This case, the Assume period is joined to Transaction. Ideally, In such cases you need to have the time/period table separately and use that

To Date =
CALCULATE(SUM(Transactions[Amount]),FILTER(ALL(Period),Period[Period] <= MAX(Period[Period])))

 

In case you have a Date, refer

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

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
Greg_Deckler
Super User
Super User

@NathanSaber - Try

Measure =
  VAR __Category = MAX('Transactions'[Category])
  VAR __Period = MAX('Period'[Period])
RETURN
  SUMX(FILTER(ALL('Transactions'),[Category]=__Category && [Period]<=__Period),[Amount])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.