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
jd8766
Helper II
Helper II

Calculate % against total correctly?

Hi, hopefully someone can advise if this can be done.

I have 2 tables in PBI, one is a subscripton fact table and one is an unsubscribe reason dimension table. (example below)

jd8766_1-1677847769397.png

 


I want to build a matrix visual in PBI that shows me the below..

jd8766_2-1677847884517.png



This is all the unsubscribe reasons, then a % of the [Cost] column associated to these unsubscribe reasons. The calc for this is 

CALCULATE(SUM(Cost),UnsubscribeReasonKey<>-1) / SUM(Cost)

However when I use this in my visual.. it shows everything as 100%.. when really I want it to show me the % of the [cost] per UnsubscribeReason vs the TOTAL cost in the Subscriptions table?

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @jd8766 

 

You can try the following methods.

Measure = 
Var _N1=CALCULATE ( SUM ( Subscriptions[Cost] ),
    FILTER ( ALL ( Subscriptions ), [UnsubscribeReasonKey] <> -1 ),
    FILTER ( ALL ( UnsubscribeReason ), [Reason] = SELECTEDVALUE ( UnsubscribeReason[Reason] )))
Var _N2=CALCULATE(SUM(Subscriptions[Cost]),ALL(Subscriptions))
Return
DIVIDE(_N1,_N2)

vzhangti_0-1678158904849.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @jd8766 

 

You can try the following methods.

Measure = 
Var _N1=CALCULATE ( SUM ( Subscriptions[Cost] ),
    FILTER ( ALL ( Subscriptions ), [UnsubscribeReasonKey] <> -1 ),
    FILTER ( ALL ( UnsubscribeReason ), [Reason] = SELECTEDVALUE ( UnsubscribeReason[Reason] )))
Var _N2=CALCULATE(SUM(Subscriptions[Cost]),ALL(Subscriptions))
Return
DIVIDE(_N1,_N2)

vzhangti_0-1678158904849.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

FreemanZ
Super User
Super User

hi @jd8766 
try like:

CALCULATE(SUM(Cost),UnsubscribeReasonKey<>-1) / 
CALCULATE(SUM(Cost), ALL(UnsubscribeReasonKey))

 

Your visual has a context, for example: a table with row field as "UnsubscribeReasonKey".

 

The first row is for 1, every SUM done in this row will filter by "UnsubscribeReasonKey" = 1, so it would be SUM("UnsubscribeReasonKey" = 1) / SUM("UnsubscribeReasonKey" = 1). Unless, you use ALL as shown in the previous response.

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!

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