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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

changing text to date format gives completely different number

Hello,

This should be simple.  I have a column of values that are formatted as text that reads "201901", "201902", etc.  I am trying to change their value to 2019-01, but when I change the format to date, the values are changed to completely random numbers.  

Steps I've taken.  

-edit query

-add column: Year-Month= Format(Volume[calendar year month], "YYYY-MM")

date.PNG

Attached is the value returned. 

2 ACCEPTED SOLUTIONS

Hi,

The first two rows will automatically appear.  For the third row, you simply have to go to Add column > Custom column and add everything you see from Date.From


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

View solution in original post

v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may use DAX below.

Year-Month =
VAR d =
    DATE ( QUOTIENT ( Volume[calendar year month], 100 ), MOD ( Volume[calendar year month], 100 ), 1 )
RETURN
    FORMAT ( d, "YYYY-MM" )
Community Support Team _ Sam Zha
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

6 REPLIES 6
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may use DAX below.

Year-Month =
VAR d =
    DATE ( QUOTIENT ( Volume[calendar year month], 100 ), MOD ( Volume[calendar year month], 100 ), 1 )
RETURN
    FORMAT ( d, "YYYY-MM" )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

The attached screenshot should say it all

Hope this helps.

Untitled.png


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

Hi,

thanks for the help. 

I tried entering this in query editor, but it didn't work. I'm brand new to power bi so this is probably on me. 

would I enter this is custom column ?

Hi,

The first two rows will automatically appear.  For the third row, you simply have to go to Add column > Custom column and add everything you see from Date.From


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

Hi @Anonymous 

You can use the below DAX patern.

Column = FORMAT('Calendar'[yearWeekNo],"")

Or if you use Query Editor M code is

Number.ToText( your number column )

hope this helps
Mariusz

Anonymous
Not applicable

Hello,

Thanks for the help.  I entered the measure above, then tried to change to Date formula and recieved #ERROR.

this is what I entered:

Calendar new type = FORMAT(Data_Volume[Calendar Year Month],"")
 
Then I went to date type, changed to date.  I recieved this error: Cannot convert value '201708' of type text to type date.
Any suggestions would be appreicated. thanks!
 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors