Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Add column with average per category

 

Hi,

 

I am a newbie at Powerbi. I want to have the average price per category.

But I don´t want to create a measure, as for me it has to be a fixed table. I manage to create a Measure, but then I can not the (price-average_price). I´d like to create a new column with the calculated field. But don´t know-how. 

The table should look something like this, and I need to add average_price to the table.

 

id        price  category     average_price

32141  100  050055555      75

32141    50  050055555      75

 

42421   300  030010402    283
42422   290  030010402    283
30074   250  030010402    283
42512   300  030010402    283
30289   250  030010402    283
49993   310  030010402    283

 

Thanks in advance

  • Hi,

    Try this calculated column formula

    Average_Price = calculate(average(Data[Price]),filter(Data,Data[category]=earlier(Data[category])))

    Hope this helps.

4 Replies

  • jaipal's avatar
    jaipal
    Resolver III

    Anonymous  hi, try this in your calculated colum

    Column = (calculate( AVERAGE('Table'[price]) ,FILTER('Table', 'Table'[category] = MAX('Table'[category]))))

     

  • Hi,

    Try this calculated column formula

    Average_Price = calculate(average(Data[Price]),filter(Data,Data[category]=earlier(Data[category])))

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    Not applicable

    thanks mate, really helped me!