Skip to content
BI Data

M Date Range Generator — Power BI Date Table

Generate Power Query M code for date ranges with daily, weekly, monthly or yearly intervals.

Use cases

Create date tables for Power BI, Excel Power Query and other compatible Microsoft tools.

Supported intervals

  • Days — daily interval
  • Weeks — weekly interval
  • Months — monthly interval
  • Years — yearly interval

Features

  • Generate Power Query M code
  • Customize the date column name
  • Validate the date range
  • Copy the code into Power Query Editor
  • Copy the result to the clipboard
First date in the range
Last date in the range
Date generation interval
Table column name (default: Date)

Generated M code


  

Power Query M reference

Using the generated code

  1. Open Power BI Desktop or Excel
  2. Open Power Query Editor
  3. Create a new query: "Data" → "Get Data" → "Blank Query"
  4. Paste the generated M code into the query editor
  5. Apply the query

Usage examples

  • Calendar table: Build a date range for your data model
  • Time series analysis: Prepare date ranges for period comparisons
  • Monthly reporting: Create monthly date intervals
  • Planning: Generate future dates for forecasts

Common M date functions

Function Description
List.Dates() Creates a list of dates with a fixed interval
List.Generate() Generates a list using a condition
Date.AddMonths() Adds months to a date
Date.AddYears() Adds years to a date
Duration.Days() Returns the number of days

Interval types

  • Days: Uses List.Dates() with #duration(1,0,0,0)
  • Weeks: Uses List.Dates() with #duration(7,0,0,0)
  • Months: Uses List.Generate() with Date.AddMonths()
  • Years: Uses List.Generate() with Date.AddYears()

More tools

Free tools for analysts and developers