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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
askspepsi
Helper II
Helper II

Extract AM / PM from Datetime format in direct query

hi all,

 

Greetings,

 

Is the way to Extract AM or PM from Datetime format in direct query without changing to Import storage.

Or is there any another way to create another table or colume to extract time and convert to AM / PM

2 ACCEPTED SOLUTIONS
dax
Community Support
Community Support

Hi @askspepsi , 

You could try to refer to @Greg_Deckler 's measure, and change it  and apply this in table visual like below

Measure = IF(RIGHT(MAX('Table1'[date]) & "",2)=SELECTEDVALUE('Table'[time]), 1,0)

793.PNG

Best Regards,
Zoe Zhi

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

@askspepsi - OK, if I understand correctly use HOUR. If it is >= 12 it is PM otherwise AM

https://docs.microsoft.com/en-us/dax/hour-function-dax



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@askspepsi Should be able to use DAX to parse that using RIGHT, like maybe:

 

Measure = RIGHT(MAX('Table'[Datetime]) & "",2)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  thanks for the update.

 

iam really sorry i was not clear in the question i asked, let me rephrase again.

 

i have column name with datetime (see the below) and create AM / PM when i select AM the 06:00 and 5:50 only and when i select PM i what 17:58 and 17:59 

2020-07-23 17:58:57.000
2020-07-23 17:59:02.000
2020-07-23 06:00:37.000
2020-07-23 05:50:25.000

@askspepsi - OK, if I understand correctly use HOUR. If it is >= 12 it is PM otherwise AM

https://docs.microsoft.com/en-us/dax/hour-function-dax



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
dax
Community Support
Community Support

Hi @askspepsi , 

You could try to refer to @Greg_Deckler 's measure, and change it  and apply this in table visual like below

Measure = IF(RIGHT(MAX('Table1'[date]) & "",2)=SELECTEDVALUE('Table'[time]), 1,0)

793.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.