Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
admin_xlsior
Post Prodigy
Post Prodigy

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
v-juanli-msft
Community Support
Community Support

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
v-juanli-msft
Community Support
Community Support

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.