M code for date and time dimension table

Is it possible to write M code for a date & time table. I’m having issues with a particular measure not working properly, or should I say Power BI not being able to cope with the large amounts of data it needs to interpret the measure. So I am exploring alternatives.

I need a table that spans just two days (1st and 2nd Feb 2020) with calendar date and month bins alongside 1 minute, 15 minute and 1 hour bins for those two days.

Any ideas?

Hi @chrisgreenslade,

There are requirements to a Date table so what you are proposing will never be a proper Date/Time dimension… That said, you can find examples in the M showcase category for both.

This topic includes a list of requirements for Date table.

.
And here is M code for a Time table, that you can adjust to your needs.

.
And here’s a topic you might also find intresting, although it’s a totally different scenario.

1 Like

Hi @Melissa. I thought As much.

I am aware of the date and time table M code and use it in all my PBIX, so I was hoping for something else, as I still can’t get your occupancy measure to work with the vast amount of information I have,