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
DataSundowner
Helper II
Helper II

Cumulative Sum Everything before the Selected Date But Ignore the Date Slicer

Hello everyone. I have a cumulative sum measure looks like below. It works fine. However, it only starts accumulating starting the start date on the date slicer. For example, if a store oepned and started having sales in 2015, it only accumulates starting 2018 if the date slicer is selected to start at 2018. I want it to accumulate starting the first possible date in the DimDate table no matter how date slicer is selected. How can I work around this? Thanks in advance! 

 

 

# Running Total Count = 
CALCULATE(
    SUM(SalesTable[Count]),
    FILTER(
        ALLSELECTED(SalesTable),
        SalesTable[SaleDate]<=MAX(DimDate[Date])
    )
)

 

 

 

1 ACCEPTED SOLUTION

@Jihwan_Kim @Greg_Deckler Thank you both for your help. I got it working with the following. 

 

CALCULATE(
    SUM(SalesTable[Count]),
    ALL(DimDate),
    FILTER(
        ALLSELECTED(SalesTable[SaleDate]),
        SalesTable[SaleDate]<=MAX(DimDate[Date])
    )
)

 

View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

Instead of using ALLSELECTED, please try using ALL, and check if it suits your requirement.

 

Thanks.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi @Jihwan_Kim, thank you for the quick reply. I had tried All, but with All, it calculates for all stores and ignores the store filter. I do want to keep the ability to calculate for only selected store. 

@DataSundowner Try this approach: (1) Better Running Total - Microsoft Power BI Community


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I changed it to the following. Looks like it's doing the same thing as my original formula. It only starts accumulating starting the start date on date slicer. 

# Running Total Count = 
VAR _maxDate = MAX(DimDate[Date])
VAR _table = FILTER(ALLSELECTED(SalesTable), SalesTable[SaleDate]<=_maxDate)

RETURN
SUMX(_table, SalesTable[Count])

 

@Jihwan_Kim @Greg_Deckler Thank you both for your help. I got it working with the following. 

 

CALCULATE(
    SUM(SalesTable[Count]),
    ALL(DimDate),
    FILTER(
        ALLSELECTED(SalesTable[SaleDate]),
        SalesTable[SaleDate]<=MAX(DimDate[Date])
    )
)

 

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.