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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
ohnothimagain
Helper I
Helper I

calculate Filterd VAR table to cumulative value

Hello everyone! I came back again,,,😣
I want to make a table filtered and summary values cumulative,but this doesn't work.How should I correct it?

 

 

Ftd_sum :=
VAR tbl = 
    SELECTCOLUMNS(
        FILTER(ALL('TEST_'), 'TEST_'[STS] = "〇"),
        "@Trg", 'TEST_'[PN]
    )
VAR Dis = 
    DISTINCT(tbl)   // OK
VAR Ftd = 
    CALCULATETABLE(
        'TEST_',
        'TEST_'[PN] IN Dis,
        FILTER(
            ALLSELECTED('Calendar'),
            'Calendar'[Date] <= MAX('Calendar'[Date])
        ),
        USERELATIONSHIP('Calendar'[Date], 'TEST_'[Calculated])
    )

VAR Result = 
    CALCULATE(
        SUM('TEST_'[Qty]), 
        KEEPFILTERS(Ftd)
    )
      
RETURN 
    Result





Table (I'm doing it on powerpivot)
ohnothimagain_0-1722874260357.png


want it to be

ohnothimagain_1-1722875044550.png


Thank you for reading,and continuous support!
Best Regards,

2 REPLIES 2
DataNinja777
Super User
Super User

Hi @ohnothimagain ,

What about modifying it as shown below?

Ftd_sum :=
VAR tbl = 
    SELECTCOLUMNS(
        FILTER(ALL('TEST_'), 'TEST_'[STS] = "〇"),
        "@Trg", 'TEST_'[PN]
    )
VAR Dis = 
    DISTINCT(tbl)   // OK
VAR Ftd = 
    CALCULATETABLE(
        'TEST_',
        'TEST_'[PN] IN Dis,
        FILTER(
            ALLSELECTED('Calendar'),
            'Calendar'[Date] <= MAX('Calendar'[Date])
        ),
        USERELATIONSHIP('Calendar'[Date], 'TEST_'[Calculated])
    )

VAR Result = 
    CALCULATE(
        SUM('TEST_'[Qty]), 
        KEEPFILTERS(Ftd)
    )
      
RETURN 
    Result

 Best regards,

Thank you for your reply!

I tried,but it returned non-cumulative values.do you have any ideas more?

ohnothimagain_0-1722929467948.png

 

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.