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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote 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
Community Champion
Community Champion

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.