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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ngadiez
Helper II
Helper II

Calculate Function with Accumulated Value and 2 Filters

I have a Measure where I want to get the Accumulated Sales

 

My Formula is

 

AccumulatedSales =
CALCULATE (
    SUM ( Table[SalesAmount] ),
    FILTER ( Table, Table[YYMM] >= MAX (Table[YYMM])-1 ),
    FILTER ( ALL ( Table[Day] ), 'Table'[Day] <= MAX ( Table[Day] ) )
)

 

First, my formula is only this

CALCULATE (
    SUM ( Table[SalesAmount] ),
    FILTER ( ALL ( Table[Day] ), 'Table'[Day] <= MAX ( Table[Day] ) )
)

Capture1.PNG

where Day is just a difference between customer subscription date to transaction date. 
Where I can get a line chart with x axis as Day and y-axis the 'Accumulated Sales'.

 

However I want to add 1 more filter before this filter where the YYMM (year and month of transaction date) is current month and last month.

MAX (Table[YYMM] ) is the current month.

 

But the accumulation function didn't work anymore. 

Capture.PNG

2 REPLIES 2
v-caliao-msft
Microsoft Employee
Microsoft Employee

@ngadiez,

 

You create a measure and use the filter FILTER ( Table, Table[YYMM] >= MAX (Table[YYMM] ) ), so you want to get a Month to Date cummulative total, right?

 

Please try the expression below.
AccumulatedSales =
CALCULATE (
    SUM ( Table[SalesAmount] ),
    FILTER ( Table, Table[YYMM] >= MAX (Table[YYMM] ) && 'Table'[Day] <= MAX ( Table[Day] ) )
)
Or you could use TOTALMTD Function to get Month to date total, it evalutes the value of the expression for the month to date, in the current context.
https://msdn.microsoft.com/en-us/library/ee634560.aspx

If this is not what you want, please provide us some sample data, so that we can make further analysis.

 

Regards,

Charlie Liao

 

Hi @v-caliao-msft

 

Really apologise that I did not explain it properly.

 

This is the sample Table

NoMemberStartDateTransactionDateMemberIDSalesAmountDay=TransactioDate-MemberStartDateYYMM
105-Apr-1505-May-17161.8                                    7611705
214-Mar-1612-May-17213.0                                    4241705
305-Apr-1531-May-17150.9                                    7871705
407-Aug-1505-Apr-17353.3                                    6071704
514-Mar-1624-Apr-17221.2                                    4061704
605-Apr-1517-May-17146.3                                    7731705
729-Nov-1505-Mar-17459.3                                    4621703
816-Nov-1523-Mar-17537.9                                    4931703
916-Nov-1513-May-17519.6                                    5441705
1007-Aug-1512-Mar-17334.4                                    5831703

Basically, I just want to make a chart where the x-axis is the day(transactiondate-startdate) and y-axis the accumulated sales amount until date.

I only need data for current month (May) and last month(April). The table has all sales amount until current month. The first filter is to get current month Max(Table[YYMM]) and Max(Table[YYMM])-1.


So I did FILTER ( Table, Table[YYMM] >= MAX (Table[YYMM]-1 ) )

 

The second filter is to do an accumulation function. I don't think I can use TotalMTD because that use date as the input where mine is a day(number).

So what I did is FILTER ( ALL ( Table[Day] ), 'Table'[Day] <= MAX ( Table[Day] ) ).

 

Hence I will get the Accumulated Sales Amount for y-axis and the day for x-axis.

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors