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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
stefani_vileva
Resolver II
Resolver II

Calculating sum based on filtered category

Hello everyone,

 

I want to calculate the sum of quantites of some products, but I have several problems. I am showing only the filtered data (based on all other categories except premium), and I want to calculate the sum of all the products where they are premium, but only for articles that are shown in the table. All of this, needs to be also calculated based on the data for the previous week (which I keep in other data table).

For example,

Article IDCategoryTotal by categoryOverall total
123x3100
234x120
123y32100
123y1100


I have used the following formula, and it calculates right, but the problem is if there is no total by category it returns a value, which is not what i want, and plus if there is no category it adds automatically some categories in the table.

 

VAR QUANTITY_PREVIOUS_WEEK = 
CALCULATE(
    SUM(Orders[packs]), 
    FILTER(ALL('Date'), 'Date'[Week rank]=PREVIOUS_WEEK),
    FILTER(ALL(Orders[Category]), Orders[Category]="Premium")
)

 

Thank you in advance for your help.

 

Kind regards,

Stefani

1 ACCEPTED SOLUTION
stefani_vileva
Resolver II
Resolver II

I have solved my problem. It looked like I should show only the only that have no blank rows with total by category.

View solution in original post

1 REPLY 1
stefani_vileva
Resolver II
Resolver II

I have solved my problem. It looked like I should show only the only that have no blank rows with total by category.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.