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

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