Forum Discussion
DAX New Column based on values from another column
- 3 years ago
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:
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
adoster ,
A new column
averagex(Filter(Table_A, [Activity] = earlier([Activity]) ), [Cost])
a new measure
averagex(Filter(allselected(Table_A), [Activity] = Max([Activity]) ), [Cost])