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
EXCHD
Frequent Visitor

Average For Previous Month and YTD in Previous Month DAX

Hi,

I am quite new to PBI. 

I am trying to show the Average of “Actual Duration” for Previous Month in a table “VMC based on Project Completion Date”. I need a dynamic measure.

 

As the date column does not show every day (meaning a row is created if there was activity that day) my understanding was that I need a Calendar Date table to use PREVIOUSMONTH or DATEADD. I have created a table "Dates" with a column "Date" from 1/01/2018 to 31/12/2021.

 

I have created relationship between two tables.

 

This is the measure I am trying to create:

AVG in PM = CALCULATE(AVERAGE('VMC based on Project Completion Date'[Actual Duration]),PREVIOUSMONTH(Dates[Date]))

 

I get blank result.

 

 

 

 

I also need to create a measure showing the YTD result in a Previous Month.

 

This is what I wrote:

 

Cycle Time = CALCULATE(AVERAGE('VMC based on Project Completion Date'[Actual Duration]),DATEADD(Dates[Date].[Date], -1,MONTH))

 

It does show the Average  of 154 which is a current YTD. But as it is April now and I had no transaction for April I could not say if the measure shows YTD for March.

 

However, when I checked what was YTD result two months ago.

Cycle Time = CALCULATE(AVERAGE('VMC based on Project Completion Date'[Actual Duration]),DATEADD(Dates[Date].[Date], -2,MONTH))

 

The result was still the same 154. 

 

 Any help will be appreciated.

 

Evgeny

 

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @EXCHD ,

 

Please provide sample data and desired output, as below link suggested.

How to Get Your Question Answered Quickly

 

Best 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
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.