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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
davide_rossi
New Member

AVERAGEX not fixed result

Good morning,

I am trying to compute a monthly average consumption per customer per selling point, 

what I would like to have is, for a given selling point, for a given month, how much is the average consumption per customer?

I used:

 

AvgSales = CALCULATE (
                          AVERAGEX (
                                  SUMMARIZE (
                                             'IT trans cc vegacrm2',
                                             'IT trans cc vegacrm2'[Year],
                                             'IT trans cc vegacrm2'[Month],
                                             'IT trans cc vegacrm2'[Selling_point_ID],
                                             'IT trans cc vegacrm2'[Customer_ID],
                                             "Consumption", SUM ( 'IT trans cc vegacrm2'[Sale_value] )
                                   ),
                                  [Consumption]
                       ),
                     ALL ( 'IT trans cc vegacrm2'[Customer_ID] )
         )

The problem is that if I make a matrix for a given selling point, and a given month (and year), the average in some cases changes across the customers, but I don't understand why
can anybody help me?
thanks very much

Davide

3 REPLIES 3
Anonymous
Not applicable

AvgSales should be simply AVERAGEX( Customers, [Consumption] ), where [Consumption] is the measure [Consumption] := SUM ( 'IT trans cc vegacrm2'[Sale_value] ). The rest is done through suitable slicing.

First of all, thank you daxer for your answer, I then tried

AvgSales = CALCULATE(
                       AVERAGEX(
                                'IT trans cc vegacrm2'[Customer_id],
                                SUM('IT trans cc vegacrm2'[Sale_value])
                                  ))
 
but I get the error saying that it cannot compute a single value for the column "customer_id" in the table 'it....' , and it suggests I would need some grouping factor
any idea?
Anonymous
Not applicable

[Consumption] must be a measure. Your formula does not work because SUM(...) is an expression, not a measure. If you want to use an expression, you must wrap it in CALCULATE that does the necessary context transition. Also, the outer CALCULATE is not needed when defining AvgSales. Moreover, you can't use a naked column under AVERAGEX as the first argument. You have to retrieve values of the column through a table expression. For instance, VALUES or DISTINCT.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors