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

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
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.