cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

New Member

## DAX - DATESADD FUNCTION (MTD AVerage of Previous Month)

Hi, I need help in this really bad.

I am trying to obtain Current MTD Average & Previous MTD Average of selected dates through a filter.

I have used the Following measure for the current MTD average:

Avg_DAILYBASE_CM =
CALCULATE(
AVERAGE('DB'[DAILY_ACTIVE])
, DATESMTD('DB'[DATA_DATE]
))
and used the Following measure for previous MTD average:
Avg_DAILYBASE_LM =
CALCULATE(
AVERAGE('DB'[DAILY_ACTIVE]),
)
The data is calculated accurately (as attached in picture), but the total average is incorrect for the previous month's MTD. Can anyone please help out in this? Would really appreciate

5 REPLIES 5
Super User

Hi @Hashmi

Avg_DAILYBASE_LM =
AVERAGEX (
VALUES ( 'DB'[DATA_DATE] ),
CALCULATE (
AVERAGE ( 'DB'[DAILY_ACTIVE] ),
DATEADD ( 'DB'[DATA_DATE], -1, MONTH )
)
)

New Member

@Mahesh0016 Hi thankyou for your reply, but unfortunately the issue still presists. after doing the recommended change the averages in days values have further become incorrect.

Plus the total average of the selected date range is of CM.

Super User

@Hashmi I hope this helps you!!THANK YOU!!
Avg_DAILYBASE_LM =
var MX_Month = MAX('DB'[DATA_DATE])-1
RETURN

CALCULATE(
AVERAGE('DB'[DAILY_ACTIVE]),
DATESINPERIOD('DB'[DATA_DATE], MX_Month,-1, MONTH)
)
Super User

@Hashmi I hope this helps you!!THANK YOU!!
var MX_Month = MAX('DB'[DATA_DATE])-1

Avg_DAILYBASE_LM =
CALCULATE(
AVERAGE('DB'[DAILY_ACTIVE]),
DATESINPERIOD('DB'[DATA_DATE], MX_Month,-1, MONTH)
)
Super User

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors