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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Create a quick calculation with a part fixed and another dependent on the filters (PowerBI - DAX)

So 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 population) / (sum of the selected attribute in absolute terms regardless of any filter / 60483973).

Can you help me?

 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you can try this measure:

Affinity =

var _sumofselected=SUMX(ALLSELECTED('Dati Popolazione ATTR'),[Population])

var _sumofall=SUMX(ALL('Dati Popolazione ATTR'),[Population])

var _divide1=DIVIDE(_sumofselected,_sumofall)

var _divide2=DIVIDE(ABS(_sumofselected),60483973)

return DIVIDE(_divide1,_divide2)

 

Then you can create a card chart to place the measure and a Slicer to place the [Attribute], like this:

v-robertq-msft_0-1606294795880.png

 

And you can get what you want.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you can try this measure:

Affinity =

var _sumofselected=SUMX(ALLSELECTED('Dati Popolazione ATTR'),[Population])

var _sumofall=SUMX(ALL('Dati Popolazione ATTR'),[Population])

var _divide1=DIVIDE(_sumofselected,_sumofall)

var _divide2=DIVIDE(ABS(_sumofselected),60483973)

return DIVIDE(_divide1,_divide2)

 

Then you can create a card chart to place the measure and a Slicer to place the [Attribute], like this:

v-robertq-msft_0-1606294795880.png

 

And you can get what you want.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , I think you need to create a measure slicer for that.


https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slicer-parameter-table-pattern
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/500115

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.