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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
danieleb75
New Member

a simple filtered subtotal

Hi

thank you in advance for you help.

 

I try to simplify my issues...

 

I'm in EXCEL, Power Pivot and I want to introduce a new calculated measure.

 

myTable

 

Code (key)Area

valueA

(explicit calculated field)

% Value of single record respect of Sub-Totale Area ValueB

(what I need)

Cod001Area1100€40%
Cod002Area1150€60%
Cod003Area2200€100%
Cod004Area3300€50%
Cod005Area3200€33%
Cod006Area3100€17%

 

I try to use EARLIER and EALRIEST but...

 

=[valueA] / CALCULATE(SUMX(FILTER(myTable;[area]=EARLIER(TAB_Baseline[area]));[valueA]))

 

doesn't work cause of area is not used before (dax error response message).

I think also that this way is cpu/time wasting cause of every row is has to re-calculate all sub-total.

What is the best way to have what I need?

Thank you

Dan

 

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@danieleb75 Try:

Column = 
  VAR __ValueA = [valueA]
  VAR __Area = [Area]
  VAR __Total = SUMX(FILTER(ALL('Table'),[Area] = __Area),[valueA])
  VAR __Result = DIVIDE(__ValueA, __Total)
RETURN
  __Result


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

I'm using measures inside Power Pivot, so I inserted your suggestion just there.

I receive an error at:

VAR __ValueA = [valueA]

 

is not possibile determinare an unique value. Also adding or not the name of table before.

 

Thank you.

@danieleb75 Try:

 

Column = 
  VAR __ValueA = MAX([valueA])
  VAR __Area = MAX([Area])
  VAR __Total = SUMX(FILTER(ALL('Table'),[Area] = __Area),[valueA])
  VAR __Result = DIVIDE(__ValueA, __Total)
RETURN
  __Result

 

I don't work in Excel but rather Power BI Desktop so no idea if this works the same.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

and than... why the use of "MAX" operator?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.