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
Anonymous
Not applicable

Average Sales

Hi Guy,

I'm trying to calculate current Year Avg sales. when i filter to current Year i get this value with sales for this year instead Avg. see DAX below

Iklizo_0-1654819142106.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I agree with vapid128 's reply. I think your average is calcualted based on years and sales measure. I think sales measure should be created by SUM() function.

My Sample:

RicoZhou_0-1655274682177.png

Measure:

Sales_ = SUM('Table'[Sales])
Avg Sales = 
CALCULATE(AVERAGEX(VALUES('Calendar'[Fiscal Year]),[Sales_]))

Result:

RicoZhou_1-1655274732125.png

You see when I select 2022, I could only get average the same as the total in 2022. If you sum to calculate the sales, Power BI will take the same year as a whole.

What kind of result do you want? If you want to get 100 as average in 2022, please do not use sales measure. 

Try this code.

Avg Sales = 
AVERAGEX('Table','Table'[Sales])

Result is as below.

RicoZhou_2-1655275087537.png

 

Best Regards,
Rico Zhou

 

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

5 REPLIES 5
vapid128
Solution Specialist
Solution Specialist

I am a little bit missunderstand, 

your [sales] should be a sum of somthing

 

Let's say 2021 sales = 200, 2020 sales =100

 

If you select 2021 2020, [sales] = 300, [avg sales] = 150

if you select 2021, [sales] = 200,  [avg sales] =200

 

everytime when you select one year, it is the sales value.

Anonymous
Not applicable

@vapid128  Everything i select 2022, it give me the same as Total year instead of avg

Hi @Anonymous ,

 

I agree with vapid128 's reply. I think your average is calcualted based on years and sales measure. I think sales measure should be created by SUM() function.

My Sample:

RicoZhou_0-1655274682177.png

Measure:

Sales_ = SUM('Table'[Sales])
Avg Sales = 
CALCULATE(AVERAGEX(VALUES('Calendar'[Fiscal Year]),[Sales_]))

Result:

RicoZhou_1-1655274732125.png

You see when I select 2022, I could only get average the same as the total in 2022. If you sum to calculate the sales, Power BI will take the same year as a whole.

What kind of result do you want? If you want to get 100 as average in 2022, please do not use sales measure. 

Try this code.

Avg Sales = 
AVERAGEX('Table','Table'[Sales])

Result is as below.

RicoZhou_2-1655275087537.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

vapid128
Solution Specialist
Solution Specialist

averagex(values([year]),calculate([sales]))

Anonymous
Not applicable

@vapid128 
The same thing result

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