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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DamienDhaene
Regular Visitor

Calculate Measure using a relationship

Hi Community,

 

I need some help solving the following question.

 

I have a table containing all contracts a team is responsible for and the % of Sales their commission is calculated on.

 

TeamContract%
AC.01100%
AC.02100%
AC.0350%
AC.04100%
BC.0150%
BC.05100%
BC.03100%
BC.06100%
BC.07100%

 

Next to that I have a contract table containing sales per Contract

 

Sales Table
ContractSales
C.01100
C.02150
C.0370
C.0480
C.05180
C.06120
C.0750

 

Sales over all contracts = 750

 

I want to create a measure that shows the Commission Sales per Team (when a team is selected) but when nothing is selected doesn't show more then total sales of all contracts = 750.

 

  Sales x %
AC.01100
AC.02150
AC.0335
AC.0480
BC.0150
BC.05180
BC.0370
BC.06120
BC.0750

 

Because contracts are not unique in the table above total Sales would be 835 in this case.

 

Relationship between the two tables is on the contract.

 

Tx

1 ACCEPTED SOLUTION

You are going to have to modify the measure to take Team totals into account. It is basically the same process as grand total lines. Check out my Matrix Measure Triple Threat Rock and Roll.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Matrix-Measure-Total-Triple-Threat-Rock-amp-...



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...

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @DamienDhaene,

 

You can also take a look at following blog to know how to calculate dax formula on hierarchy total level:

Clever Hierarchy Handling in DAX

 

Regards,

Xiaoxin Sheng

Greg_Deckler
Community Champion
Community Champion

You can create a couple of measures and you want to use Measure 2 in your table visualization. Based on this Quick Measure, Measure Totals, The Final Word:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Measure = SUMX(FILTER(ALL(Table2),'Table2'[Contract]=MAX('Table1'[Contract])),[Sales])*MAX([%])

Measure 2 = 
VAR __sum = SUMX('Table2',[Sales])
RETURN
IF(HASONEVALUE('Table1'[Team]),[Measure],__sum)

Attached PBIX for your reference.

 

 



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...

@Greg_Deckler Tx for your reply, with the measure you propose I can see that the calculation works on the contract level, however when introducing a slicer on the Team, totals per team do not match the sum of their contracts.  When looking at individual teams Totals should match the sum of their contracts, when not selecting any team total should be total of the contracts (without duplication)

 

In this case Total

 

Team A = 365

Team B = 470

 

Grand Total (without slicing on team) 750

 

You are going to have to modify the measure to take Team totals into account. It is basically the same process as grand total lines. Check out my Matrix Measure Triple Threat Rock and Roll.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Matrix-Measure-Total-Triple-Threat-Rock-amp-...



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...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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