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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply

PREVIOUS MONTH returns blank

Hello experts,

 

I want to retrieve the nb_conv_int for the last month so I used PREVIOUS MONTH as you can see below:

Nb_conv M-1:=CALCULATE([Nb_conv_inter];PREVIOUSMONTH(Date_table[Date]))

But, it returns blank value:

FranckGbadamass_2-1661270428022.png

 

I don't know what's going wrong. Here is my data (if you want to help)

 

Below my data model:

FranckGbadamass_1-1661270173623.png

Thanks in advance.

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @FranckGbadamass ,

 

In order to use any time intelligence calculation, you need a well-formed date table. The Date table must satisfy the following requirements:

  • All dates need to be present for the years required. The Date table must always start on January 1 and end on December 31, including all the days in this range. If the report only references fiscal years, then the date table must include all the dates from the first to the last day of a fiscal year. For example, if the fiscal year 2008 starts on July 1, 2007, then the Date table must include all the days from July 1, 2007 to June 30, 2008.
  • There needs to be a column with a DateTime or Date data type containing unique values. This column is usually called Date. Even though the Date column is often used to define relationships with other tables, this is not required. Still, the Date column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.
  • The Date table must be marked as a date table in the model, in case the relationship between the Date table and any other table is not based on the Date.

The result of time intelligence functions has the same data lineage as the date column or table provided as an argument.

Note: The result table includes only dates that exist in the dates column.

Please check your Date column, or use something to replace the PREVIOUSMONTH fumction:

Nb_conv M-1 = CALCULATE([Nb_conv_inter],Filter('Date_table',[Date]<=EOMONTH(MAX('Date_table'[Date]),-1)&&[Date]>=EOMONTH(MAX('Date_table'[Date]),-2)+1))

 

Best Regards,

Jianbo Li

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

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

I wouldn't use PREVIOUSMOTH as it does not work the way people would expect it to. Instead, use a different function, DATEADD, that does work the way you'd expect. If you want to know how the functions differ, please go to https://dax.guide/previousmonth and https://dax.guide/dateadd and see the examples there (they're interactive).

v-jianboli-msft
Community Support
Community Support

Hi @FranckGbadamass ,

 

In order to use any time intelligence calculation, you need a well-formed date table. The Date table must satisfy the following requirements:

  • All dates need to be present for the years required. The Date table must always start on January 1 and end on December 31, including all the days in this range. If the report only references fiscal years, then the date table must include all the dates from the first to the last day of a fiscal year. For example, if the fiscal year 2008 starts on July 1, 2007, then the Date table must include all the days from July 1, 2007 to June 30, 2008.
  • There needs to be a column with a DateTime or Date data type containing unique values. This column is usually called Date. Even though the Date column is often used to define relationships with other tables, this is not required. Still, the Date column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.
  • The Date table must be marked as a date table in the model, in case the relationship between the Date table and any other table is not based on the Date.

The result of time intelligence functions has the same data lineage as the date column or table provided as an argument.

Note: The result table includes only dates that exist in the dates column.

Please check your Date column, or use something to replace the PREVIOUSMONTH fumction:

Nb_conv M-1 = CALCULATE([Nb_conv_inter],Filter('Date_table',[Date]<=EOMONTH(MAX('Date_table'[Date]),-1)&&[Date]>=EOMONTH(MAX('Date_table'[Date]),-2)+1))

 

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors