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
Anonymous
Not applicable

Trouble with Date Table starting in July

Hi,

Hi, I am trying to create a data table for 2020 and 2021. I have a date table defined like this:

Date =
VAR __startDate = DATE ( 2020, 1, 1 )
VAR __endDate = DATE ( YEAR ( TODAY() ), 12, 31 )
VAR __dates = CALENDAR(__startDate,__endDate)
RETURN
ADDCOLUMNS (
__dates,
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month Name", FORMAT ( [Date], "MMM" ), --use MMMM for full month name, January instead of Jan
"Month", FORMAT( [Date], "MMM, YYYY" ), --use MMMMM for full month name, January instead of Ja
"Month Sort", FORMAT( [Date], "YYYY-MM" ),
"Quarter", "Q" & FORMAT( [Date], "Q, YYYY" ),
"Quarter Sort", FORMAT ( [Date], "YYYY-Q" )
)
 
and for some reason its starting on July 1 2020 instead of Jan 1, 2020
russgove2_0-1632833579234.png

 

If I remove the two Quarter columns :
Date =
VAR __startDate = DATE ( 2020, 1, 1 )
VAR __endDate = DATE ( YEAR ( TODAY() ), 12, 31 )
VAR __dates = CALENDAR(__startDate,__endDate)
RETURN
ADDCOLUMNS (
__dates,
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month Name", FORMAT ( [Date], "MMM" ), --use MMMM for full month name, January instead of Jan
"Month", FORMAT( [Date], "MMM, YYYY" ), --use MMMMM for full month name, January instead of Ja
"Month Sort", FORMAT( [Date], "YYYY-MM" )
)
 
Then it starts in January as I want.
russgove2_1-1632833666749.png

 

 

How do i get it always to start in January?

 

(I've been taking all sorts of online training and I recall somhere they showed me how to change the fiscal year settings and that likely whats happenning, but I cant find out where I did that)

 

TIA

 

Russell

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

That code works fine for me.  Try sorting the Date column in Ascending order and you'll see 1 Jan 2020.

dt3.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Doh!

Thanks, was just not sorted

PhilipTreacy
Super User
Super User

Hi @Anonymous 

That code works fine for me.  Try sorting the Date column in Ascending order and you'll see 1 Jan 2020.

dt3.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.