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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
MSA247
Regular Visitor

Power BI Desktop, How to convert a column in Text format to Date format. Error after 3 method tried.

Situation 1 - Column in Whole Number but have 0 in it. (refer picture 1 below)
Issue 1 - Column in Whole Number but have 0 in it.Issue 1 - Column in Whole Number but have 0 in it.

Issue - When divide the whole number to day, month, and year, the month column cannot change to whole number format, can only remain in text format. (Picture 2 below)
Issue 2 - When divide the whole number to day, month, and year, the month column cannot change to whole number format, can only remain in text format.Issue 2 - When divide the whole number to day, month, and year, the month column cannot change to whole number format, can only remain in text format.

Method 1 - NOK, tried to do it using DAX, same DAX works with T1RPRD Column but not with T1DELD column. The difference between these 2 columns are T1DELD have 0 while T1RPRD dont have 0 in it. (Picture 3 below)
Method 1 - NOK, tried to do it using DAX, same DAX works with T1RPRD Column but not with T1DELD column. The difference between these 2 columns are T1DELD have 0 while T1RPRD dont have 0 in it.Method 1 - NOK, tried to do it using DAX, same DAX works with T1RPRD Column but not with T1DELD column. The difference between these 2 columns are T1DELD have 0 while T1RPRD dont have 0 in it.

Method 2 - NOK, Tried using formula DATE by combining Column Day T1DELD, Month T1DELD, and year T1DELD but not working as only the column Month T1DELD is in text format, others are in whole number format. (Picture 4 below)
Method 2 - NOK, Tried using formula DATE by combining Column Day T1DELD, Month T1DELD, and year T1DELD but not working as only the column Month T1DELD is in text format, others are in whole number format.Method 2 - NOK, Tried using formula DATE by combining Column Day T1DELD, Month T1DELD, and year T1DELD but not working as only the column Month T1DELD is in text format, others are in whole number format.

Method 3 - NOK, Using directly formula substract 2 column with text format to produce vehicle age in days are totally and obviously wrong. (Picture 5 below)
Method 3 - NOK, Using directly formula substract 2 column with text format to produce vehicle age in days are totally and obviously wrong.Method 3 - NOK, Using directly formula substract 2 column with text format to produce vehicle age in days are totally and obviously wrong.

Expected Result - Exactly like Picture 3, column T1RPRD, eg from whole number 20180629 to date 26/06/2018.

Please help me dear comunity, I am stuck.

1 ACCEPTED SOLUTION
Bmejia
Super User
Super User

In your method 1, you can remove the zeros to blanks during the transformation and then transform the column to date.  
or if you want to keep the zero's then use iferror to exclude zeros in your measure or column

Return = IFERROR(Date('year,'month,'day),BLANK())

View solution in original post

5 REPLIES 5
Bmejia
Super User
Super User

In this case a blank is equal to null, I am not and expert, but in my own experiense I have ran into situation where blanks to not act like null value.  That would be a whole different topic that you can research.

Bmejia
Super User
Super User

In your method 1, you can remove the zeros to blanks during the transformation and then transform the column to date.  
or if you want to keep the zero's then use iferror to exclude zeros in your measure or column

Return = IFERROR(Date('year,'month,'day),BLANK())

IT WORKS! Again thank you soo much how you have help me solve my issue, how grateful I am for that!
Solved! for the non-zero part!Solved! for the non-zero part!

You can't keep the zero but you can replace it with another date value.  That you would know represents a zero

IFERROR(DATE('Table'[DateVar],'Table'[month],'Table'[DAY]),DATE(1900,1,1))

Ahh i see~ I think I would keep it as it is but just wondering tho, BLANK() is equal to NULL? Thank you soo much 😄

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.