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
Birinder
Helper III
Helper III

How to create a new subtotal column from Measures ?

Hi there,

 

As in the first picture you can see that I have 3 columns. What I want to achieve here is the exact solution as picture second. Now I will explain. 

As you can see there is a column named as "Quarter", which contains 2 values-Q1 and Q2. I want to total the sales column values according to the Quarter Category. Same as it is happening in the 2nd Picture. I want to do this, to calculate the margin afterwords.

BUT HERE IS A TWIST:

I know how to do this, in M code and Power Query. But I want the solution, If we want to create this kind of column as a new measure. I can't figure out the solution for this case.

 

Thanks and regards.

 

 

Screenshot (64).pngScreenshot (66).png

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Birinder I think  you want:

Sub-Total Each Category Measure = 
  VAR __Quarter = MAX('Table'[Quarter])
RETURN
  SUMX(FILTER(ALL('Table'),[Quarter]=__Quarter),[Sales])


Margin Measure =
  [Sub-Total Each Category Measure] - MAX('Table'[Sales])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Birinder
Helper III
Helper III

@Greg_Deckler 

Hi there, 

Thanks for the reply.

 

I want to ask you, Will this work if All the three columns ; "Quarter", "Model" and "Sales" are from 3 seperate tables, and are connected via relationship.

If Yes, then Inplace of "table" in code given by you, What am I supposed to enter.

 

Thanks and Regards

Greg_Deckler
Super User
Super User

@Birinder I think  you want:

Sub-Total Each Category Measure = 
  VAR __Quarter = MAX('Table'[Quarter])
RETURN
  SUMX(FILTER(ALL('Table'),[Quarter]=__Quarter),[Sales])


Margin Measure =
  [Sub-Total Each Category Measure] - MAX('Table'[Sales])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.