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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Credo
Helper I
Helper I

Calculate subtotal using dax

I would like to calculate a subtotal using dax (not using the subtotal feature of matrix visual)

 

Sample data: 

 

ClientShopSales
A1100
A2200
B3400
B4500

 

 

Desired outcome: 

I want a measure that can calculate Client total for the displayed Shop without adding the client field itself to the visual

 

ShopClient Total
1300
2300
3900
4900

 

Best I could come up with was 

CALCULATE(SUM('Table1'[Sales]); ALL('Table1'[Shop]))

 

but it just gives me a repeating 1200 across all shops as it should unless I add client field to the table.

 

How can I add filter context for the client into the measure if its not part of a visual? 

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Credo Please try this as a "New Measure"

 

Test107 = CALCULATE(SUM(Test107Measure[Sales]),FILTER(ALL(Test107Measure),Test107Measure[Client]=SELECTEDVALUE(Test107Measure[Client]))) 

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Add as measure

 

TotVal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Client]))

PattemManohar
Community Champion
Community Champion

@Credo Please try this as a "New Measure"

 

Test107 = CALCULATE(SUM(Test107Measure[Sales]),FILTER(ALL(Test107Measure),Test107Measure[Client]=SELECTEDVALUE(Test107Measure[Client]))) 

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Thanks a lot

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.