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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
alexa_0028
Resolver II
Resolver II

Calculate Average sales for a given year/week number and particular salesperson

Hi All,

I want to calculate average sales for the given year/week/salesperson, I am not able to get the right result.
Can someone please help me?

alexa_0028_0-1638203933887.png

DASX for Weekly Avg =


CALCULATE(AVERAGEX(Sales,[Sales]),
ALLEXCEPT('Calendar','Calendar'[D. Week],'Calendar'[D. Year])
,ALLEXCEPT('SalesPerson ','SalesPerson'[salesperson]))



1 ACCEPTED SOLUTION

How about this then?

Daily Avg per Week =
CALCULATE (
    AVERAGEX ( VALUES ( 'Calendar'[Date] ), CALCULATE ( SUM ( Sales[Sales] ) ) ),
    ALL ( 'Calendar'[D. Day of Week] )
)

View solution in original post

6 REPLIES 6
alexa_0028
Resolver II
Resolver II

Hi @AlexisOlson 
Thank you again, for finding time to help me with this.
I am actually looking for something like this :

alexa_0028_0-1638207639138.png


Average sales based on week/year/salesperson only .
With your updated dasx I am not getting the right result, it is showing me the same output for weekly average column.


How about this then?

Daily Avg per Week =
CALCULATE (
    AVERAGEX ( VALUES ( 'Calendar'[Date] ), CALCULATE ( SUM ( Sales[Sales] ) ) ),
    ALL ( 'Calendar'[D. Day of Week] )
)

Thank you so much @AlexisOlson 
This works for me perfectly 🙂

alexa_0028
Resolver II
Resolver II

Hi @AlexisOlson 
Thanks for your reply but this is giving me weekly average same as sales value now and also removing blank rows.

alexa_0028_0-1638205308966.png

 

Ah, I misunderstood what you meant by "weekly average". It looks like you actually want a daily average.

 

See if this works like you expect:

 

Daily Avg =
CALCULATE (
    AVERAGEX ( VALUES ( 'Calendar'[Date] ), CALCULATE ( SUM ( Sales[Sales] ) ) ),
    ALLSELECTED ( 'Calendar' )
)

 

AlexisOlson
Super User
Super User

You need to make sure you're averaging at the right granularity. AVERAGEX( Sales, [Sales] ) iterates through every row of the Sales table and takes the average of [Sales] over all of those rows rather than taking the weekly average.

 

I'd try something like this to do a weekly average:

 

Weekly Avg =
VAR YearWeeks =
    CALCULATETABLE (
        SUMMARIZE ( 'Calendar', 'Calendar'[D. Year], 'Calendar'[D. Week] ),
        ALLSELECTED ( 'Calendar' )
    )
RETURN
    AVERAGEX ( YearWeeks, CALCULATE ( SUM ( Sales[Sales] ) ) )

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.