cancel
Showing results for
Did you mean:
Highlighted
Member

## AVERAGEX and CALCULATE

Hi,

Recently I'm confuse oh using AVERAGE or AVERAGEX function.

For example I have this Sales data (at first) :

 SalesID SalesTeritory OrderDate Amount SO-01 EAST 1/1/2019 500 SO-02 EAST 1/1/2019 100 SO-03 WEST 1/1/2019 200 SO-04 WEST 1/3/2019 300 SO-05 WEST 2/1/2019 100

I create a simple measure for the Total amount :

[Total amount] = SUM(Sales[Amount])

Then there is requirement which I need to join to some table and it product some duplicate row because of the join.

 SalesID SalesTeritory OrderDate Amount Location SO-01 EAST 1/1/2019 500 Main W/H SO-02 EAST 1/1/2019 100 Main W/H SO-03 WEST 1/1/2019 200 Main W/H SO-03 WEST 1/1/2019 200 Aisle 2 SO-04 WEST 1/3/2019 300 Main W/H SO-05 WEST 2/1/2019 100 Main W/H

I need my Total Amount measure handle this duplicate rows, so I thought average between these duplicate value will do the trick, but apperntly not.

At first I created this addtional measure :

Total amount average = IF(
HASONEVALUE('Sales'[SalesId]),
[Total amount],
AVERAGEX(KEEPFILTERS(
VALUES('Sales'[SalesId])
),
CALCULATE([Total amount])
)
)

Do I need to use COUNTROWS and use DIVIDE instead ?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: AVERAGEX and CALCULATE

If you add all column on the table visual, please create a measure

`Measure = CALCULATE(AVERAGE('Table'[Amount]),ALLEXCEPT('Table','Table'[SalesID],'Table'[OrderDate],'Table'[SalesTeritory]))`

If you only add SalesID, SalesTeritory, OrderDate, Amount on the table, just create the measure

`Measure 2 = AVERAGE('Table'[Amount])`

Please use Performance Analyzer to examine and conpare report element performance when using "average" and "averagex", so to define which function to use.

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Support Team

## Re: AVERAGEX and CALCULATE

If you add all column on the table visual, please create a measure

`Measure = CALCULATE(AVERAGE('Table'[Amount]),ALLEXCEPT('Table','Table'[SalesID],'Table'[OrderDate],'Table'[SalesTeritory]))`

If you only add SalesID, SalesTeritory, OrderDate, Amount on the table, just create the measure

`Measure 2 = AVERAGE('Table'[Amount])`

Please use Performance Analyzer to examine and conpare report element performance when using "average" and "averagex", so to define which function to use.

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

Kudos to you if you earned one of these! Check your inbox for a notification.

#### Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

#### Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (3,431)