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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
paschott
Regular Visitor

Want to create a single-value average from prior three months

We had a report that was calculating an average from the prior 3 months (not including the current month). I'm trying to recreate that in DAX now and not sure how to go about it.

 

I tried:

Prev3MonthsAvgVisits = CALCULATE(AVERAGE(MonthlySummary[Visits]), DATESBETWEEN(dimDate[Date], DATEADD(dimDate[Date], -4, MONTH), DATEADD(dimDate[Date], -1, MONTH)))

 

That's valid DAX and seems to be what I want, but when I try to use that in my table, I get "A table of multiple values was supplied where a single value was expected."

 

 

How would I go about getting this value to work and return a single value per row rather than the table short of some direct query? Is there a column I can create that would do something similar?  Am I going about this in completely the wrong manner?

1 ACCEPTED SOLUTION

Turns out I was looking for an AVERAGEX function instead:

 

AVERAGEX(

    DATESBETWEEN(

    'dimDate'[Date],

    DATEADD(LASTDATE('dimDate'[Date]), -4, MONTH),

    DATEADD(LASTDATE('dimDate'[Date]), -1, MONTH)

  ),

  CALCULATE(SUM('MonthlySummary'[Visits]))

)

View solution in original post

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @paschott

 

I think this might be close...

 

Measure = CALCULATE(
			AVERAGE('MonthlySummary'[Visits]) ,
			DATESINPERIOD(
				'MonthlySummary'[Month],
				DATEADD(
					LASTDATE('MonthlySummary'[Month]),
					-1,
					MONTH
					),
				-3,
			MONTH)
			)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Turns out I was looking for an AVERAGEX function instead:

 

AVERAGEX(

    DATESBETWEEN(

    'dimDate'[Date],

    DATEADD(LASTDATE('dimDate'[Date]), -4, MONTH),

    DATEADD(LASTDATE('dimDate'[Date]), -1, MONTH)

  ),

  CALCULATE(SUM('MonthlySummary'[Visits]))

)

Hi @paschott,

 


AVERAGEX(

    DATESBETWEEN(

    'dimDate'[Date],

    DATEADD(LASTDATE('dimDate'[Date]), -4, MONTH),

    DATEADD(LASTDATE('dimDate'[Date]), -1, MONTH)

  ),

  CALCULATE(SUM('MonthlySummary'[Visits]))

)


 

Have you resolved original problem and achieved your requirement with above modified formula? If yes, would you please kindly mark your shared solution as an answer so that it can benefit more users? If not, can you post the image of the unexpected result you got?

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors