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

List of Dates

Hi guys!

 

How can I make a list of dates, more especificaly months, between two dates?

 

Something like 'ListOfMonths(StartDate;EndDate)'

 

And if I use it like this

 

ListOfMonths(01/01/2019;31/12/2019)

 

the result will be

 

Months
janeiro-19
fevereiro-19
março-19
abril-19
maio-19
junho-19
julho-19
agosto-19
setembro-19
outubro-19
novembro-19
dezembro-19

 

 

1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@BlackBird ,

 

Create new table using below DAX formula:

Calendar Table= CALENDAR(DATE(2019,1,1),DATE(2019,12,31))

 

Don't forget to hit Thumbs up and accept this as a solution if you find it helpful! 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @BlackBird 

 

Try this function in Power Query, you will need to paste the below into Blanc Query, you can Invoke by providing start and end dates or add it to your existing table by going to Add Column > Invoke Custom Function and use columns from your table for start and end dates.

(#"Start Date" as date, optional #"End Date" as date ) => let
    enddate = if #"End Date" = null then DateTime.Date( DateTime.LocalNow() ) else  #"End Date", 
    days = Duration.Days( enddate - #"Start Date" ) +1,
    listDates = List.Dates( #"Start Date", days, #duration( 1, 0, 0, 0 ) ),
    monthYear = List.Transform( listDates, each  Date.Year( _ ) * 100 + Date.Month( _ ) ),
    listMonthYear = List.Distinct( monthYear )
    
in
    listMonthYear

 

Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.

 

Tahreem24
Super User
Super User

@BlackBird ,

 

Create new table using below DAX formula:

Calendar Table= CALENDAR(DATE(2019,1,1),DATE(2019,12,31))

 

Don't forget to hit Thumbs up and accept this as a solution if you find it helpful! 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.