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
DevidsU
Frequent Visitor

Stop cumulative from resetting when filtering by month

Hi,

When using this expression the cumulative total shows correct values but it resets when I slice it by single month.

CALCULATE (
SUM ( ITEM_Ledger_entry[Quantity] ),
FILTER (
ALLSELECTED( ITEM_Ledger_entry ),
ITEM_Ledger_entry[Posting_Date] <= MAX ( ITEM_Ledger_entry[Posting_Date]
)))

CumulativeCorrect.png

And when I use the ALLEXCEPT version of expression the cumulative total shows wrong cumulatives or it selects way too many but it doesn't reset when I filter it by month, which is exactly what I need.

CALCULATE (
SUM(ITEM_Ledger_entry[Quantity]), FILTER( ALLEXCEPT(ITEM_Ledger_entry, ITEM_Ledger_entry[Posting_Date].[Date]), ITEM_Ledger_entry[Posting_Date] <= MAX(ITEM_Ledger_entry[Posting_Date])))

CumulativeIncorrect.png

I tried combining both ALLSELECTED with except but that didn't seem to work.

Any help will be appreciated!

1 ACCEPTED SOLUTION
DevidsU
Frequent Visitor

Seems like this one has the desired result I needed.

VAR currentYear = MAX(ITEM_Ledger_entry[Posting_Date].[Year])
VAR currentProduct = MAX(ITEM_Ledger_entry[Item_Description])
VAR currentPostingDate = MAX(ITEM_Ledger_entry[Posting_Date])
RETURN
 
 SUMX( 
        FILTER (
                ALL ( ITEM_Ledger_entry ),
                     ITEM_Ledger_entry[Item_Description] = currentProduct &&
                     ITEM_Ledger_entry[Posting_Date].[Year] <= currentYear &&
                     ITEM_Ledger_entry[Posting_Date] <= currentPostingDate 
                   
            ),
            ITEM_Ledger_entry[Quantity]
        )
    

View solution in original post

2 REPLIES 2
DevidsU
Frequent Visitor

Seems like this one has the desired result I needed.

VAR currentYear = MAX(ITEM_Ledger_entry[Posting_Date].[Year])
VAR currentProduct = MAX(ITEM_Ledger_entry[Item_Description])
VAR currentPostingDate = MAX(ITEM_Ledger_entry[Posting_Date])
RETURN
 
 SUMX( 
        FILTER (
                ALL ( ITEM_Ledger_entry ),
                     ITEM_Ledger_entry[Item_Description] = currentProduct &&
                     ITEM_Ledger_entry[Posting_Date].[Year] <= currentYear &&
                     ITEM_Ledger_entry[Posting_Date] <= currentPostingDate 
                   
            ),
            ITEM_Ledger_entry[Quantity]
        )
    
amitchandak
Super User
Super User

@DevidsU , waht do mmeas by resetiing here ?

Can you share sample data and sample output in table format?

 

Try with all

CALCULATE (
SUM ( ITEM_Ledger_entry[Quantity] ),
FILTER (
ALL( ITEM_Ledger_entry ),
ITEM_Ledger_entry[Posting_Date] <= MAX ( ITEM_Ledger_entry[Posting_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.