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

Can't get previous months data

Hi all,

 

I'm trying to get the previous months data from the table I have to put alongside the current months but the calculations I'm doing are not returning the results I expect.

 

If I use 

 

available_count_LM = calculate(sum(FINAL[available]), PREVIOUSMONTH(DATES[report_period_end].[Date]))

Then no data is returned in the last month column.

 

 

If I use 

 

available_count_LM = calculate(sum(FINAL[available]), PARALLELPERIOD(DATES[report_period_end].[Date], -1, MONTH))

Then the same values for the current month are returned for last month. 

 

Dummy data:

 

FINAL table:

 

report_period_end,place,available,ReportingPeriod
31/10/2016,1,16382086,1617 M7
30/11/2016,1,16090055,1617 M8
31/12/2016,1,15746408,1617 M9
31/10/2016,2,15966152,1617 M7
30/11/2016,2,16249744,1617 M8
31/12/2016,2,16127134,1617 M9
31/10/2016,3,16143120,1617 M7
30/11/2016,3,15914663,1617 M8
31/12/2016,3,15941826,1617 M9

 

DATES Table:

 

ReportingPeriod,report_period_start,report_period_end
1617 M7,01/10/2016,31/10/2016
1617 M8,01/11/2016,30/11/2016
1617 M9,01/12/2016,31/12/2016

 

Thanks

1 ACCEPTED SOLUTION
SqlJason
Memorable Member
Memorable Member

Can you ensure the following is true?

 

When using date tables to invoke time intelligence in DAX there are three fundamental principles that must always be applied.

  • The date range must be continuous in the Date tableThat is there must not be any dates missing in the column that contains the list of calendar days in the table of dates.
  • The date range in the Date table must encompass all the dates that you will be using in other tables in the data model.
  • For time intelligence in Power BI Desktop to work correctly the fields used to join a date table and a data table must both be set to the date or datetime data type.

View solution in original post

2 REPLIES 2
SqlJason
Memorable Member
Memorable Member

Can you ensure the following is true?

 

When using date tables to invoke time intelligence in DAX there are three fundamental principles that must always be applied.

  • The date range must be continuous in the Date tableThat is there must not be any dates missing in the column that contains the list of calendar days in the table of dates.
  • The date range in the Date table must encompass all the dates that you will be using in other tables in the data model.
  • For time intelligence in Power BI Desktop to work correctly the fields used to join a date table and a data table must both be set to the date or datetime data type.

Hi Jason,

 

Thanks for your response. The second two are true. The first isn't. I was using the distinct dates from my table as the only ones I use are the ones at the end of the month and so only 12 dates in a year rather than having to create a full date table to cover all years etc.

 

Thanks for answering and I'll guess I'll just create one.

 

Much appreciated.

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.