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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
adoster
Resolver I
Resolver I

DAX New Column based on values from another column

Hello,

 

Here is a simplified example of a new column I would like to create.

On TABLE_A I would like to create a New column that shows the difference between the Budget and the AVERAGE cost by Activity

 

TABLE_A

PersonActivityCostBudget
JohnBiking1015
LauraCamping2025
MichaelHiking3035
AdamBiking2025
LauraCamping3035
MichaelHiking4045
JohnBiking3030
RachelCamping4040
MichaelHiking5050

 

END RESULT

would either have 2 new column or just the Difference

 

PersonActivityCostBudgetAVGCost of ActivityDifference b/t Budget & AVGCost
JohnBiking101518.75-3.75
LauraCamping202528.75-3.75
MichaelHiking303538.75-3.75
AdamBiking202518.756.25
LauraCamping303528.756.25
MichaelHiking404538.756.25
JohnBiking303018.7511.25
RachelCamping404028.7511.25
MichaelHiking505038.7511.25
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @adoster 

According to your description, you want to add two columns to calculate the " AVERAGE cost by Activity" and the "Differences betwwen budget and AVERAGE cost by Activity".

For your test data , in the [Activity]="Biking" , the [AVERAGE cost by Activity] should = (10+20+30)/3 =20.

But in your expected table , the number is not right i think.

Here are the steps you can refer to :
(1)You can click "New Column" and enter:

AVGCost of Activity = var _activity= [Activity]
var _t =FILTER('Table','Table'[Activity]=_activity)
return
AVERAGEX(_t, [Cost])
Difference b/t Budget & AVGCost = [Budget]-[AVGCost of Activity]

(2)Then we can get your need:

vyueyunzhmsft_0-1671590565253.png

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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-yueyunzh-msft
Community Support
Community Support

Hi , @adoster 

According to your description, you want to add two columns to calculate the " AVERAGE cost by Activity" and the "Differences betwwen budget and AVERAGE cost by Activity".

For your test data , in the [Activity]="Biking" , the [AVERAGE cost by Activity] should = (10+20+30)/3 =20.

But in your expected table , the number is not right i think.

Here are the steps you can refer to :
(1)You can click "New Column" and enter:

AVGCost of Activity = var _activity= [Activity]
var _t =FILTER('Table','Table'[Activity]=_activity)
return
AVERAGEX(_t, [Cost])
Difference b/t Budget & AVGCost = [Budget]-[AVGCost of Activity]

(2)Then we can get your need:

vyueyunzhmsft_0-1671590565253.png

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

@adoster ,

A new column

averagex(Filter(Table_A, [Activity] = earlier([Activity]) ), [Cost])

 

a new  measure

 

averagex(Filter(allselected(Table_A), [Activity] = Max([Activity]) ), [Cost])

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