cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

DAX LAST7DAYS AVG

Hi,

 

Why do huge difference is coming between Last7d(22425822 etc) and Last7d avg(13.09 etc) values which has shown in below table.could any one please modify my dax.

 

Last7d =
CALCULATE (
SUMX(sales,sales[salesdetail.qty]),
DATESINPERIOD ( 'Calendar'[Date],LASTDATE ('Calendar'[Date]),-7,DAY )
)
 
Last7d avg =
CALCULATE (
AVERAGE (sales[salesdetail.qty]),
DATESINPERIOD ( 'Calendar'[Date],LASTDATE('Calendar'[Date]),-7,DAY )
)

  

Last7d        Last7d avg  Date
22425822     13.09     1-Aug-19
30914263     11.89     2-Aug-19
8642104       11.13     3-Aug-19
7504866       11.25    4-Aug-19
9374137       9.91      5-Aug-19
7521041       9.06       6-Aug-19
8354975       8.54       7-Aug-19
8453644       8.88       8-Aug-19
8137744       9.19       9-Aug-19
2 REPLIES 2
Highlighted
Frequent Visitor

Re: DAX LAST7DAYS AVG

Hey, 

 

My guess is that you are using SUMX instead of SUM, so you are basically summing the entire sales table and then calculate what that is for the 7d.

 

Try changing SUMX by SUM

 

Highlighted
Super User IV
Super User IV

Re: DAX LAST7DAYS AVG

Have you check manually which one is correct. Check the Sum and Avg using this

Sales 10 Days = ( 
VAR _Cuur_start = Max('Compare Date'[Compare Date]) -7
VAR _Curr_END = Max('Compare Date'[Compare Date])
return 
calculate((sum(Sales[Sales Amount]),Sales[Sales Date] >= _Cuur_start && Sales[Sales Date] <=  _Curr_END )
)

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors