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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
duggy
Advocate II
Advocate II

Generate date column using generate series

Hi,

 

I have the following formula that generates a new table with a row for each day between a start and end date from a given table:

 

Events Table = 
SELECTCOLUMNS (
    GENERATE (
        'specialdays',
        GENERATESERIES (
            CALCULATE ( VALUES ( 'specialdays'[startspecialdaydate] ) ),
            CALCULATE ( VALUES ( 'specialdays'[Endspecialdaydate] ) )
        )
    ),
    "locationId", 'specialdays'[locationId],
    "specialday", 'specialdays'[specialdayname]
)

 

the result is:

 

StoreIdspecialdayname
7601Mother's Day
7601Mother's Day
7601Mother's Day
7601Mother's Day

 

That is all good and well and seems to be working fine. However i want to add a column with the subsequent date of the generatedseries. So if I have a row in the table:

 

LocationIdspecialdaynamestartspecialdaydateEndspecialdaydate
7601Mother's DayThursday, 05 July 2018Sunday, 08 July 2018

 

Then the result should be:

StoreIdspecialdaynameDate
7601Mother's Day05-Jul-18
7601Mother's Day06-Jul-18
7601Mother's Day07-Jul-18
7601Mother's Day08-Jul-18

 

Can anyone suggest how I can achieve this?

Much appreciated.

1 ACCEPTED SOLUTION
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @duggy,

Based on my test, you could refer to below steps:

Create a calender table:

Date Table = CALENDAR(MAX('Table2'[startspecialdaydate]),MAX('Table2'[Endspecialdaydate]))

1.PNG

Create a new table:

Result Table = SUMMARIZECOLUMNS('Table1'[StoreId],'Table1'[specialdayname],'Date Table'[Date])

Result:

2.PNG

 

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @duggy,

Based on my test, you could refer to below steps:

Create a calender table:

Date Table = CALENDAR(MAX('Table2'[startspecialdaydate]),MAX('Table2'[Endspecialdaydate]))

1.PNG

Create a new table:

Result Table = SUMMARIZECOLUMNS('Table1'[StoreId],'Table1'[specialdayname],'Date Table'[Date])

Result:

2.PNG

 

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli
Community Champion
Community Champion

It might not be exactly what you're looking for but if we start with your 'specialdays' table, create a calendar table on the fly and do a cross-join...

SpecDateTable = 
         VAR Mday = FILTER(specialdays, specialdays[Specialdayname] = "Mother's Day")
	 VAR MdayData = SELECTCOLUMNS(Mday, "ID" , specialdays[LocationId], "DayName", specialdays[Specialdayname])
	 VAR Calt  = CALENDAR(SELECTCOLUMNS(Mday, "StartDay", specialdays[Startspecialdaydate]),
			SELECTCOLUMNS(Mday, "EndDay", specialdays[Endspecialdaydate]))
	
	RETURN GENERATE(MdayData, Calt)

Should give you the result you want.

Ashish_Mathur
Super User
Super User

Hi,

 

As long as data in the 3rd and 4th columns are actual dates, you should be able to get your desired result by using the following M code

 

={Number.From([startspecialdaydate[)..Number.From([Endspecialdaydate])}


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

Sorry, not following. Are you saying to create a new column in the specialdays table and use the code:

theeventdates = {Number.From([startspecialdaydate])..Number.From([Endspecialdaydate])}

 

I get the syntax for 'From' is incorrect when I try this.

Hi,

 

That M code has to be written int he Query Editor.  In the Query Editor, go to Add Column > Custom column


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.