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
jmercado
Frequent Visitor

Date Format

Hello,

 

Im trying to Format a column in a Date format, the current column show as this 20200501 (05/01/2020).

 

im curretling using the formula:

Sold Date=Date(Left(DQPCDH[DCDATE],4),Right(left(DQPCDH[DCDATE],6),2),right(DQPCDH[DCDATE],2))

 

That Formula works Great if the table looks like the below table.

 

ProductSold date 1Sold date
Bike2020060406/04/2020
Ball2020040504/05/2020

 

but im getting a error due to some of the spaces are blank or Zero.

 

ProductSold date 1Sold Date
Bike20200604#ERROR
Ball0#ERROR

 

 

 

 
 
 
 
 

 

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hello @jmercado ,

You can test this calculated column.

Sold Date = IF([Sold date 1]<>0|| [Sold date 1]<>BLANK(),Date(Left([Sold date 1],4),Right(left([Sold date 1],6),2),right([Sold date 1],2)))

7.png

Best regards

Stephen Tao

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hello @jmercado ,

You can test this calculated column.

Sold Date = IF([Sold date 1]<>0|| [Sold date 1]<>BLANK(),Date(Left([Sold date 1],4),Right(left([Sold date 1],6),2),right([Sold date 1],2)))

7.png

Best regards

Stephen Tao

If this post helps,then consider Accepting it as the solution to help other members find it faster.

Anonymous
Not applicable

Shouldn't that formula use && rather than ||  ?

Sold Date = IF([Sold date 1]<>0 && [Sold date 1]<>BLANK(),Date(Left([Sold date 1],4),Right(left([Sold date 1],6),2),right([Sold date 1],2)))

 

CNENFRNL
Community Champion
Community Champion

Hi, @jmercado , just set back and relax. Power Query is capable of convert such 8-digit dates with ease!

Screenshot 2020-10-26 233128.png

 

Or if you insist on doing it youself,

Screenshot 2020-10-26 234039.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

mahoneypat
Employee
Employee

You could do this pretty easily in the query editor, but if you want to make a DAX column, you can just wrap your expression in IFERROR()

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.