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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ngomes
Helper II
Helper II

Calculate accumulated value with dax

I created a new measure to calculate the accumulated quantities
The measure calculates the values until the end of the year but what I wanted was for the calculation to be done only up to the current month or up to the maximum date it finds

 

Accumulated Quantities =
IF(
ISFILTERED('Database'[Date]),
ERROR("Primary date."),
TOTALYTD(SUM('Database'[Quantity]), 'Database'[Date].[Date])
)

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Try:

Cumulative value =
IF (
    MAX ( Database[Data].[Date] ) < TODAY (),
    CALCULATE (
        SUM ( Database[Preço Líquido (MBase)] ),
        FILTER (
            ALL ( 'Database' ),
            Database[Data].[Date] <= MAX ( Database[Data].[Date] )
        )
    )
)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

Try:

Cumulative value =
IF (
    MAX ( Database[Data].[Date] ) < TODAY (),
    CALCULATE (
        SUM ( Database[Preço Líquido (MBase)] ),
        FILTER (
            ALL ( 'Database' ),
            Database[Data].[Date] <= MAX ( Database[Data].[Date] )
        )
    )
)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






thanks for your help my friend

I took part of the formula you sent me and it was like this

 

Preço Líquido (MBase) YTD =
IF (MAX ( Database[Data].[Date] ) < TODAY (), IF(
    ISFILTERED('Database'[Data]),
    ERROR("Data primária."),
    TOTALYTD(SUM('Database'[Preço Líquido (MBase)]), 'Database'[Data].[Date])
))
amitchandak
Super User
Super User

@ngomes , Example with help from date tbale

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

 

or

calculate(SUM('Database'[Quantity]), filter(allselected('Database') , 'Database'[Date] <= max('Database'[Date]) ) )

 

or

 

calculate(SUM('Database'[Quantity]), filter(all('Database') , 'Database'[Date] <= max('Database'[Date]) ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I've already tested the formulas, but I still have the same problem
notice the example I put
in December I have no values and the sum goes from November to December

 

calculate(SUM(Database[Preço Líquido (MBase)]), filter(all('Database') , Database[Data].[Date] <= max(Database[Data].[Date]) ) )
 
Sem Título.jpg

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors