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

How can I stop cumulative total?

Hi, how can I stop the cumulative measure to stop at June? and reflect only blank values starting July?

 

11

 

Some DAX I tried:

#1. 

Cumulative try (II) = VAR _max = MAXX(ALL('Date Table- DIM'[Date]),'Date Table- DIM'[Date])
Return
CALCULATE('Important Measures'[Actuals(I)],FILTER(ALL('Date Table- DIM'[Date]),'Date Table- DIM'[Date]<=MAX('Date Table- DIM'[Date]) && 'Date Table- DIM'[Date]<=_max))
 
#2. 
Cumulative Actuals try (I) = VAR LastDatee = CALCULATE(MAX('Date Table- DIM'[Date]),LASTDATE('Date Table- DIM'[Date]))
VAR VisualDate = MAX('Date Table- DIM'[Date])
Return
IF(VisualDate<=LastDatee, CALCULATE('Important Measures'[Actuals(I)],FILTER(ALLSELECTED('Date Table- DIM'[Date]),'Date Table- DIM'[Date]<=MAX('Date Table- DIM'[Date]))))

 

Both are not solving the purpose (Stopping cumulative from July Onwards)

 

Thank you so much in advance 🙂

1 ACCEPTED SOLUTION
ribisht17
Super User
Super User

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@Anonymous best practice is to add a column in your date table that checks for the last available date with sales, something like
DateWithSales =
INT('Date'[Date] <= MAX ( Sales[Order Date] ))
Then add it as filter to the filter pane of the report and set it to 1.

You can also do it robust to not need to add it to the filter pane by adding it to all your measures.
Somthing like, create this measure:

 

ShowValueForDates :=
VAR LastDateWithData =
    CALCULATE (
        MAX ( 'Sales'[Order Date] ),
        REMOVEFILTERS ()
    )
VAR FirstDateVisible =
    MIN ( 'Date'[Date] )
VAR Result =
    FirstDateVisible <= LastDateWithData
RETURN
    Result

 


And then add it to your measure:

 

Sales YTD :=
IF (
    [ShowValueForDates],
    CALCULATE (
        [Sales Amount],
        DATESYTD ( 'Date'[Date] )
    )
)

 


Anyway, for full explanation just go to the source 🙂 sqlbi.com:
https://www.daxpatterns.com/standard-time-related-calculations/




2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

ribisht17
Super User
Super User

@Anonymous 

 

Please refer to this solution Solved: Cumulative total - stopping after last date not wo... - Microsoft Power BI Community

 

Regards,

Ritesh

Anonymous
Not applicable

Thank you @ribisht17  I had to make some tweaks to make it work.  Actually, the column I am using to generate the cumulative series is a measure. I defined the measure again in the maxx() function. This worked.

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.