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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Quick calculation where numerator depends on filters but denominator is fixed (DAX)

I have a table in PowerBI called "Dati Popolazione ATTR", which is something like:

Region | Province | Town | Population | Males | Females | Attribute
R1 | P1 | T1 | 1000 | 500 | 500 | A1
R1 | P1 | T1 | 1000 | 500 | 500 | A2
R1 | P1 | T1 | 1000 | 500 | 500 | A3
R2 | P2 | T2 | 2000 | 600 | 1400 | A1
R2 | P2 | T2 | 2000 | 600 | 1400 | A2
R2 | P2 | T2 | 2000 | 600 | 1400 | A3
R3 | P3 | T3 | 1500 | 550 | 950 | A1
R3 | P3 | T3 | 1500 | 550 | 950 | A2
R3 | P3 | T3 | 1500 | 550 | 950 | A3

I want to create a quick measure called 'Affinity'. This should have the following calculation:

Affinity = sum of the selected attribute / sum of the selected attribute in absolute terms regardless of any filter

Denominator should not vary if I select any filter.

Can you help me?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Check the formula and if the result is what you want. If not, please show the expected result to us.

Affinity = CALCULATE(SUM('Table'[Population]),ALLSELECTED('Table'))/CALCULATE(SUM('Table'[Population]),ALL('Table'))

19.PNG20.PNG 

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Check the formula and if the result is what you want. If not, please show the expected result to us.

Affinity = CALCULATE(SUM('Table'[Population]),ALLSELECTED('Table'))/CALCULATE(SUM('Table'[Population]),ALL('Table'))

19.PNG20.PNG 

 

Best Regards,

Jay

MFelix
Super User
Super User

Hi @Anonymous ,

 

You should do a measure similar to the one below:

 

Affinity = DIVIDE(SUM(Table[Population]), CALCULATE(SUM(Table[Population]),ALL(Attribute)))

 

Using the ALL syntax will allow you to get the values without any filtering.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors