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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Average DAX

Hi,

 

I am getting huge difference between Last X Days Sales(i.e below hundred) and Average Last X Days Sales (aroung 1 million). can any one tell me what is wrong with Average Last X Days Sales measure.

 

 

Last X Days Sales =
VAR day =
IF ( ISINSCOPE ( 'Calendar'[Month Number] ), -[NumberOfDays in Current Month],
IF ( ISINSCOPE ( 'Calendar'[Quarter Name] ), -[Number of days in Quarter],
IF ( ISINSCOPE ( 'Calendar'[Date] ), -7, -1 )
))
RETURN
CALCULATE (
SUM(sales[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), day, DAY )
)

Average Last X Days Sales =
VAR day =
IF ( ISINSCOPE ( 'Calendar'[Month Number] ), -[NumberOfDays in Current Month],
IF ( ISINSCOPE ( 'Calendar'[Quarter Name] ), -[Number of days in Quarter],
IF ( ISINSCOPE ( 'Calendar'[Date] ), -7, -1 )
))
RETURN
CALCULATE (
AVERAGEX ( sales, sales[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), day, DAY )
)

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

I reproduced your question, but didn't meet any issue. Maybe you could try it again. And if there is still any issue, please let me know and give me more details.

last.PNG

Best Regards,
Icey

 

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

Anonymous
Not applicable

Hi,

These are the measures that i am using. still getting wrong values. could anyone please modify the below measures.



Last X Days Sales =
VAR day =
IF (ISINSCOPE ( 'Calendar'[Year] ), -[NumberOfDays in Current Year],
IF ( ISINSCOPE ( 'Calendar'[Quarter Name] ), -[Number of days in Quarter],
IF ( ISINSCOPE ( 'Calendar'[Month Number] ), -[NumberOfDays in Current Month],
IF ( ISINSCOPE ( 'Calendar'[Date] ), -7, -1 )
)))
RETURN
CALCULATE (
SUMX(sales,sales[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), day, DAY )
)

Average Last X Days Sales =
VAR day =
IF (ISINSCOPE ( 'Calendar'[Year] ),-[NumberOfDays in Current Year],
IF (ISINSCOPE ( 'Calendar'[Quarter Name] ), -[Number of days in Quarter],
IF (ISINSCOPE ( 'Calendar'[Month Number] ), -[NumberOfDays in Current Month],
IF (ISINSCOPE ( 'Calendar'[Date] ), -7, -1 )
)))
RETURN
CALCULATE (
AVERAGEX (sales, salesDetail[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE('Calendar'[Date] ), day, DAY )
)
rsimonsen
Frequent Visitor

This might be as simple as you are using sum instead of sumx.

 

Yours-

RETURN
CALCULATE (
SUM(sales[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), day, DAY )
)

 

Change to 

RETURN
CALCULATE (
SUMX(sales[salesDetail.qty]),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), day, DAY )
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.