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
Anonymous
Not applicable

Running total column with many filters

I have table "Sales" (fields: Product, Country, Date, Sales) with monthly sales across many products and countries. Also I have tables with calendar, list of products, list of counties that are linked with this table. I want to add column to "Sales" with running total sales across each Product/Country, see the field with desired result "Running total".

 

I tried to use YTD = TOTALYTD(SUM(Sales[Sales]); Calendar[Date]) but it didn't work. I think I need to use filters in TOTALYTD function, but I also didn't manage to understand how. Can you suggest to me a right solution to my case?

 

 

ProductCountryDateSales,
tons
Running
total, tons
AUSJan-181010
AUSAug-18515
AUSFeb-192020
AUSMay-19525
ACanadaMar-1811
ACanadaDec-1834
ACanadaFeb-1977
ACanadaJun-191017
BUKFeb-1844
BUKSep-1815
BUKJan-1988
BUKOct-19412
BGermanyMar-181515
BGermanyNov-18318
BGermanyFeb-1977
BGermanyMay-1918
CJapanMar-182020
CJapanJul-181131
CJapanOct-1922
CJapanNov-1957
CKoreaFeb-1855
CKoreaMar-18712
CKoreaJun-1911
CKoreaJul-19910
1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

You may refer to the DAX below.

Column =
SUMX (
    FILTER (
        Sales,
        Sales[Product] = EARLIER ( Sales[Product] )
            && Sales[Country] = EARLIER ( Sales[Country] )
            && Sales[Date] <= EARLIER ( Sales[Date] )
            && YEAR ( Sales[Date] ) = YEAR ( EARLIER ( Sales[Date] ) )
    ),
    Sales[Sales]
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

You may refer to the DAX below.

Column =
SUMX (
    FILTER (
        Sales,
        Sales[Product] = EARLIER ( Sales[Product] )
            && Sales[Country] = EARLIER ( Sales[Country] )
            && Sales[Date] <= EARLIER ( Sales[Date] )
            && YEAR ( Sales[Date] ) = YEAR ( EARLIER ( Sales[Date] ) )
    ),
    Sales[Sales]
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks, your solution was successful.

Anonymous
Not applicable

I partially coped with my issue by creating set of measures for each combination of product and country:

 

A_US = TOTALYTD(SUM(Sales[Sales]);'Calendar'[Date];FILTER(All(Sales);Sales[Product]="A"&&Sales[Country]="US"))

A_Canada = TOTALYTD(SUM(Sales[Sales]);'Calendar'[Date];FILTER(All(Sales);Sales[Product]="A"&&Sales[Country]="Canada"))

 

and so on.

 

But what if i have 100 products and 30 countries? I think I need to create a column "Running total" in "Sales" that calculates running total for each product and aech country.

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
Top Kudoed Authors