cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

AVERAGEX and CALCULATE

Hi,

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

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

SalesIDSalesTeritoryOrderDateAmount
SO-01EAST1/1/2019500
SO-02EAST1/1/2019100
SO-03WEST1/1/2019200
SO-04WEST1/3/2019300
SO-05WEST2/1/2019100

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.

SalesIDSalesTeritoryOrderDateAmountLocation
SO-01EAST1/1/2019500Main W/H
SO-02EAST1/1/2019100Main W/H
SO-03WEST1/1/2019200Main W/H
SO-03WEST1/1/2019200Aisle 2
SO-04WEST1/3/2019300Main W/H
SO-05WEST2/1/2019100Main 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 ?

 

Kindly advise,

 

Thanks

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: AVERAGEX and CALCULATE

Hi @admin_xlsior 

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])

Capture11.JPG

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.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: AVERAGEX and CALCULATE

Hi @admin_xlsior 

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])

Capture11.JPG

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.

View solution in original post

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

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

Microsoft Implementation for Communities Wins Award

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

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (1,317)