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
BILearner
Advocate I
Advocate I

Measure to Sum specific rows and the subtotal/grand total to still display the Actual Total Sales

Hi Power BI Community,

I have a table displayed like below, with column definitions as follows.

Tot Sales = Sum(Sales)
My Formula = Is my attempt to get the expected result.
Expected Result = How I want the calculation to work. 

 Combine Two Rows.jpg

 

 Here is the DAX I wrote 


SUMX(SUMMARIZE(SalesFact,'Territory'[Territory ID],'Product'[Sales Role]),IF('Product'[Sales Role]="Cat 1 Rep",CALCULATE([Total Sales],'Product'[Cat 1 Product]="YES",ALL('Product')),IF('Product'[Sales Role]="Cat 2 Rep",CALCULATE([Total Sales],'Product'[Cat 2 Rep Product]="YES"),CALCULATE([Total Sales],'Product'[Cat 3 Rep Product]="YES"))))

The above formula gives me the expected result against the Cat 1 Rep row, but fails to get the expected sub total and grand total. 

The field "Cat 1 Rep Product" in above formula is a flag which identifies products from product table that fall into Cat 1.
"Cat 2 Rep Product" and "Cat 3 Rep Product" are similar columns.
   
What I want is - Sum the results for Cat 1 Rep row and Cat 2 Rep row and display it against the Cat 1 rep, other rows shouldn't be impacted. Also, I do not want this manipulation to impact the Column subtotal or grand total and should display the actual total that is (Cat 1 Rep Product + Cat 2 Rep Product + Cat 3 Rep Product) and
NOT ( (Cat 1 Rep Product + Cat 2 Rep Product) + Cat 2 Rep Product + Cat 3 Rep Product).  

Is this possible? 

Thank you all! 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@BILearner , you have to use isinscope and isfiltered to get correct subtotal and grand totals

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@BILearner , you have to use isinscope and isfiltered to get correct subtotal and grand totals

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

Top Solution Authors