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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
toziu
Regular Visitor

question of datesinperiod

there are dates from 2017/1/1 to2018/9/6

when i create a table:  table = datesinperiod ('sheet1'[date] , max('sheet1'[date]) , -1,year),the result is that it starts from 2017/10/1 to 2018/9/6,just 341days.

 

if i try : table = datesinperiod ('sheet1'[date] , date (2018,9,1), -1 ,year),the result is correct ,from 2017/9/2 to 2018/9/1 

and other dates are also correct ,just the max(date) is wrong ,what is the problem?

 

thanks very much,guys.

1 ACCEPTED SOLUTION

i have used calendar to create the table.now i can use  datesbetween('sheet'[date],edate(max('sheet'[date]),-12)+1,max('sheet'[date]))  to avoid this problem. thank you.

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

I think you're probably getting into trouble here by not using a proper Dates table.  DATESINPERIOD needs a contiguous dates table to work correctly.  That's just an educated guess since I can't see your data.

--

If you want to create a dates table use CALENDAR function. 

i have used calendar to create the table.now i can use  datesbetween('sheet'[date],edate(max('sheet'[date]),-12)+1,max('sheet'[date]))  to avoid this problem. thank you.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

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