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
Anonymous
Not applicable

Missing latest date using List.Min and List.Max

I've generated a calendar table based on dates that exist in another table (so, "Give me all of the dates that appear in this other table").

 

Here's the m defining the start and end dates in my calendar table:

 

let StartDate = List.Min(Table[as_of_date]), EndDate = List.Max(Table[as_of_date]),
DayCount = Duration.Days(Duration.From(EndDate - StartDate)),
Source = List.Dates(StartDate,DayCount,#duration(1,0,0,0)),
TableFromList = Table.FromList(Source, Splitter.SplitByNothing()), ...

 

However, when I stack my source table and calendar table side-by-side, the latest date is always missing from my calendar table:

DateIssue.JPG

Please help! What am I doing wrong?

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Add + 1 to your duration, 

= Duration.Days(Duration.From(EndDate - StartDate ))+ 1

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@Anonymous 

Add + 1 to your duration, 

= Duration.Days(Duration.From(EndDate - StartDate ))+ 1

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

I just encountered the same problem again, and this solution worked again.

@Fowmy , what is it about the Duration.Days function that requires +1? Why won't this work without +1?

@Anonymous 

By adding +1, you ensure that all days between the dates are included.
If StartDate = 1/1/2020 and EndDate = 1/5/2020 then you need the results inclusive of both dates which is 5.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn
 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy  Got it. So in M, the function Start Date - End Date is not inclusive, and +1 makes it so. Thanks!

Anonymous
Not applicable

Worked a treat! Thanks!

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.

Top Solution Authors
Top Kudoed Authors