cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hwang Frequent Visitor
Frequent Visitor

DAX - Extract Date from TimeStamp (contain date & time)

Dear Experts,

 

Which formula I can use to extract date from time stamp contains date & time?

 

Table looks like this on the table 'Date' [Date]

 

Date

1/1/2018 12:00:00AM

 

DAX being tried: DATE('Date'[Date])  --> no result.


Can brief me any easy fix for this?

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hi @Hwang,

 

Please check what data type of your Date column firstly.

 

If your Date column is Date/Time type in Power BI, you only need to change the Data format to be M/d/yyyy under Modeling.

 

change date format.PNG

 

If your Date column is Text type in Power BI, you could create the measure with the fomula below.

 

Measure 2 = LEFT(MAX('Table2'[Date]),9)

Here is the result.

 

get date.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

Hwang Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

@v-piga-msft I don't have access for modelling the SQL database.

 

The measure looks legit, I will try on it. Thank you 🙂

View solution in original post

9 REPLIES 9
chirayuw Member
Member

Re: DAX - Extract Date from TimeStamp (contain date & time)

=FORMAT('Date'[Date], "dd/mm/yyyy")*1

dujos Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hello Hwang, see in the picture below the result.

IMPORTANT use a calculated Column to FORMAT DAX function works fine.

 

sorry the menus are in portuguese but i think you can identify the itens easy

and the date format fuction uses FORMAT(table[field];"mm/dd/yyyy")

 

Good Luck!!!

 

 

img1.png

Hwang Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

 

 Hi,

 

Format doesn't work. Any idea? Below is the view pop up.

 

https://drive.google.com/file/d/19poSGC_YQfRr4fMfutQ5YDC9njGK4vtR/view?usp=sharing

 

 

Hwang Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hi Dujos,

 

The problem is i don't have access to the modelling tab, because its a company SQL BI cube.

I'm only able to modify the visual and and make DAX measure in the report.

 

I have tried above solution with FORMAT( 'Date'[Date],"dd/mm/yyyy)*1 but it also doesn't provide any result.

 

 

Super User IV
Super User IV

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hi,

 

Try this calculated column formula

 

=INT('Date'[Date])

 

Format this column as Date.


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

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hi Ashish & all experts here,

 

Thanks for all your advice, i guess i have to check on the source of my 'Date' [Date] table column, because in the formula, it has the red underlined. 

Highlighted
Community Support Team
Community Support Team

Re: DAX - Extract Date from TimeStamp (contain date & time)

Hi @Hwang,

 

Please check what data type of your Date column firstly.

 

If your Date column is Date/Time type in Power BI, you only need to change the Data format to be M/d/yyyy under Modeling.

 

change date format.PNG

 

If your Date column is Text type in Power BI, you could create the measure with the fomula below.

 

Measure 2 = LEFT(MAX('Table2'[Date]),9)

Here is the result.

 

get date.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

Hwang Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

@v-piga-msft I don't have access for modelling the SQL database.

 

The measure looks legit, I will try on it. Thank you 🙂

View solution in original post

nadavsn Frequent Visitor
Frequent Visitor

Re: DAX - Extract Date from TimeStamp (contain date & time)

try [DateTime].Date

Works for me.

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors