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
Jackofall
Resolver I
Resolver I

Date Table, add a text column as well

This works well but I want one column to come out as text so I don't have to change it afterwards.

Date = 
ADDCOLUMNS (
CALENDAR (DATE(2000;1;1); DATE(2025;12;31));
"DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
"Year"; YEAR ( [Date] );
"Monthnumber"; FORMAT ( [Date]; "MM" );
"PeriodMånad"; FORMAT ( [DATE]; "YYYYMM" );
"YearMonthnumber"; FORMAT ( [Date]; "YYYY/MM" );
"YearMonthShort"; FORMAT ( [Date]; "YYYY/mmm" );
"MonthNameShort"; FORMAT ( [Date]; "mmm" );
"MonthNameLong"; FORMAT ( [Date]; "mmmm" );
"DayOfWeekNumber"; WEEKDAY ( [Date] );
"DayOfWeek"; FORMAT ( [Date]; "dddd" );
"DayOfWeekShort"; FORMAT ( [Date]; "ddd" );
"Quarter"; "Q" & FORMAT ( [Date]; "Q" );
"YearQuarter"; FORMAT ( [Date]; "YYYY" ) & "/Q" & FORMAT ( [Date]; "Q" ))

I want "PeriodMånad"; FORMAT ( [DATE]; "YYYYMM" ); to be text or integer from start. I tried Date.ToText but that is M not DAX.

I am thinking

"PeriodMånad"; MagigTextFunction(FORMAT ( [DATE]; "YYYYMM" ));

FORMAT only handles dates and number. Finally I tried this.

"PeriodMånad"; TRIM(FORMAT ( [Date]; "YYYYMM" ));

  Now the column comes out as Text from the start but it feels awkward.

 

Is there a corresponding way of creating a date table in M from the bat? I am not fond of doing this in the end of my modelling.

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@Jackofall

 

You dont need to create a custom calendar using DAX.

 

There are already custom calendars, created using Power Query, available online.

You can also download the customer calendar from this link.

 

Obviously you can add more info to it if you want

 

If you want to move it across reports just simply copy and paste it.

 

 

View solution in original post

2 REPLIES 2
themistoklis
Community Champion
Community Champion

@Jackofall

 

You dont need to create a custom calendar using DAX.

 

There are already custom calendars, created using Power Query, available online.

You can also download the customer calendar from this link.

 

Obviously you can add more info to it if you want

 

If you want to move it across reports just simply copy and paste it.

 

 

Thanks I will look at it.

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.