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
ItsPS
New Member

Calculating Contribution to Change for a dataset

Hi All,

 

I'm trying to calculate the Cont to Chage column in PowerBI Dax but struggling to do so :

We have to Sum of Diff column based on following logic:
1. When LEVEL 3, LEVEL 4 and LEVEL 5 are blank then check the differnece between Value TY and Value PY, it it is positive, than take the sum of all the values which are positive in Difference column where LEVEL 4 and LEVEL 5 are blank and show it in Base_Total coumn. To Calculate the Cont to Change, its always 100% when LEVEL 3, LEVEL 4 and LEVEL 5 are blank, rest it should be Difference divided by Base_Total. For Negative values of Difference column it shoud be blank

2. When LEVEL 3, LEVEL 4 and LEVEL 5 are blank then check the differnece between Value TY and Value PY, it it is negtaive, than take the sum of all the values which are negative in Difference column where LEVEL 4 and LEVEL 5 are blank and show it in Base_Total coumn. To Calculate the Cont to Change, its always 100% when LEVEL 3, LEVEL 4 and LEVEL 5 are blank, rest it should be Difference divided by Base_Total. For positive values of Difference column it shoud be blank

 

Note : There are multiple LEVELS in LEVEL 2 for each Store

StoreLEVEL 2LEVEL 3LEVEL 4Value TYValue PYDifferenceBase_totalCont to Change
AHS  129079714.6125453294.73626419.98583514.55100%
AHS1-2 M1 M21143243.3618751140.92392102.468583514.5528%
AHS1-2 M2 M39758681.0634379155.165379525.98583514.5563%
AHS1-2 M 60901924.4253130296.067771628.368583514.5591%
AHS3 M 3064078529828898.81811886.198583514.559%
AHS4+ M 37537026.8542494099.8-4957072.958583514.55 
BHS  119191481126313240.1-7121759.16-7121726.6100%
BHS1-2 M 5285143553873788.1-1022353.09-7121726.614%
BHS1-2 M1 M21184857.1218142429.723042427.41-7121726.6 
BHS1-2 M2 M31666567.0335731358.38-4064791.35-7121726.6100%
BHS3 M 30155189.832097831.04-1942641.24-7121726.627%
BHS4+ M 36184899.5940341631.86-4156732.27-7121726.658%
BAH  119191481126313240.1-7121759.16-9249119.9100%
BAH35 - 49 33923704.1642592811.77-8669107.61-9249119.994%
BAH50+ 78725040.3876597649.212127391.17-9249119.9 
BAH50+50-6453384601.1952509008.51875592.684-9249119.9 
BAH50+65+25340439.1824088651.551251787.63-9249119.9 
BAHUpto 34 6542776.5917122788.925-580012.334-9249119.96%
1 REPLY 1
Elcin_7
Helper I
Helper I

Hi, Question is not that clear there is no level 5 in the table. But I will explain how I would approch as far as I understood. I would create a conditional coloumn in power query and I would say if  level 2 and level 3 and level 4 is "null" tell "emthy" and else "data". And I would create a DAX formula depending this logic.

Difference TY PY =
IF(
    SELECTEDVALUE('Sheet1'[Custom]) = "Emthy",
    SUM('Sheet1'[Value TY]) - SUM('Sheet1'[Value PY]),
    0
)

 

With similar logic if the new calculated colum is "emthy" and you can show cont to change as %100 with If formula or else you can create your calculation. 

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.

Top Solution Authors