Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
DASX for Weekly Avg =
Solved! Go to Solution.
How about this then?
Daily Avg per Week =
CALCULATE (
AVERAGEX ( VALUES ( 'Calendar'[Date] ), CALCULATE ( SUM ( Sales[Sales] ) ) ),
ALL ( 'Calendar'[D. Day of Week] )
)
Hi @AlexisOlson
Thank you again, for finding time to help me with this.
I am actually looking for something like this :
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] )
)
Hi @AlexisOlson
Thanks for your reply but this is giving me weekly average same as sales value now and also removing blank rows.
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' )
)
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] ) ) )
User | Count |
---|---|
77 | |
75 | |
46 | |
31 | |
28 |
User | Count |
---|---|
99 | |
93 | |
50 | |
49 | |
46 |