# Measure calculates cumulative sales

I am asking for help in a measure that calculates cumulative sales

@Harris

When I make cumulative measures based on dates the DAX looks like the below, where Forecast USD Total is my sum measure and I have a dedicated Dates table.

Cumulative Forecast =
CALCULATE( [Forecast USD Total],
FILTER( ALLSELECTED( Dates ),
Dates[Date] <= MAX( Dates[Date] ) ) )

Your model has a dedicated Date table, but have you tried making another dedicated table for those 15-minute intervals youâ€™ve called out to narrow down that context further?

The Measure shows that â€śSalesâ€ť is being filtered instead of dates.

Below is a simplified version with the small correction I made:

``````Cumulative_Sales =
CALCULATE ([SalesDaily],
FILTER (ALLSELECTED ( Dim15mPeriods ),
Dim15mPeriods[Dateto] <= MAX ( Sales[Dateto] )
)
)
``````

``````Sales_Cumulative =
VAR LastSalesHour = CALCULATE ( MAX ( Sales[Dateto] ), ALL ( Sales ) )
RETURN
IF (SELECTEDVALUE ( Sales[Dateto] ) > LastSalesHour,
BLANK (),
CALCULATE ([SalesDaily],
FILTER (ALLSELECTED ( Dim15mPeriods ),
Dim15mPeriods[Dateto] <= MAX ( Dim15mPeriods[Dateto] )
)
)
)
``````

1 Like

Hi @Harris, a response on this post has been tagged as â€śSolutionâ€ť. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box. Thanks!

Hi, powerbideveloper
Thank you for your help. Measure works perfectly.
We have also a second need.

If we have two lines in the same table, but we have more than 1 Store, we need another measure that will be a sum of cumulative sales for this â€śdatefrom-datetoâ€ť period for a day, so it will be the same value in both rows
also, sum of cumulative sales_exceptSelected must be the same sum, but except value of Sales_Cumulative in current row.
:

Date / Weekday / StoreName / Datefrom / Dateto / Sales / Sales_Cumulative / Sum_Sales_Cumulative / Sum_Sales_Cumulative_ExceptSelected

01.04.2019 / Monday / Store1 / 11:15 / 11:30 / 68.10 / 71.90 / 351.90 / 280.00
01.04.2019 / Monday / Store2 / 11:15 / 11:30 / 100.00 / 200.00 / 351.90 / 151.90
01.04.2019 / Monday / Store3 / 11:15 / 11:30 / 50.00 / 80.00 / 351.90 / 271.90

how to create Sum_Sales_Cumulative and Sum_Sales_Cumulative_ExceptSelected measures?

@Harris