Forum Discussion

adoster's avatar
adoster
Resolver I
3 years ago
Solved

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 Ac...
  • v-yueyunzh-msft's avatar
    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