Forum Discussion
get the months from 2 dates
- Anonymous6 years ago
The Calendar function will only create a table with all days- it's made that way so it works with Power Bi's built-in time intelligence functions. If you want to avoid this, you'd have to create your own table. The easiest way is probably just to create an excel book with a row for each month with "Datetime , MonthNumber , MonthName" and import the data from there. Do keep in mind that the datetime object does need to include a day, probably the first of the month, so that Power Bi recognizes it as a datetime.
Paste the following directly into the formula bar. The syntax should be correct- it works in the pbix I created.
Thanks alot. I will mark your answer as the solution. Also, you created the Date table for every single day but I just want a date table with the month and year,
jan 2020
feb 2020
march 2020
... Is that going to affect anything?
- Anonymous6 years agoNot applicable
It won't affect anything. I added every day because you gave the dates with a day number, and if they do have day numbers every date should exist in the dimension table. It won't affect anything, but if you do only need months you can feel free to trim down the table.
- saanah20196 years agoHelper II
Ok thanks, I will figure out how to trim my data to make it MM YYYY but how do I do that with the Date table you created?
- Anonymous6 years agoNot applicable
The Calendar function will only create a table with all days- it's made that way so it works with Power Bi's built-in time intelligence functions. If you want to avoid this, you'd have to create your own table. The easiest way is probably just to create an excel book with a row for each month with "Datetime , MonthNumber , MonthName" and import the data from there. Do keep in mind that the datetime object does need to include a day, probably the first of the month, so that Power Bi recognizes it as a datetime.