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

Help with shift mapping by date and time

Hello,

 

Could somebody help me with measure which should produce "Entry_Date" as the earliest date between 2 dates with time between 15:00 PM to next day 03:00 AM from "Created". 

 

Thanks,

 

CreatedEntry_Date
11/10/2021 16:2311/10/2021
11/10/2021 17:2311/10/2021
11/10/2021 18:2311/10/2021
11/10/2021 18:2711/10/2021
11/10/2021 19:1011/10/2021
11/10/2021 19:3011/10/2021
11/11/2021 0:3011/10/2021
11/11/2021 0:3511/10/2021
11/11/2021 0:4511/10/2021
11/11/2021 1:3011/10/2021
11/11/2021 2:3011/10/2021
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this code to add a new column to your table:

Column = 
Var _Time = TIMEVALUE([Created])
Var _S = time(15,00,00)
Var _E = time(3,0,0)
return
format(if(_Time<_E,DATEVALUE([Created])-1,DATEVALUE([Created])),"MMMM DD")

 

Output:

VahidDM_0-1636588429949.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!


LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this code to add a new column to your table:

Column = 
Var _Time = TIMEVALUE([Created])
Var _S = time(15,00,00)
Var _E = time(3,0,0)
return
format(if(_Time<_E,DATEVALUE([Created])-1,DATEVALUE([Created])),"MMMM DD")

 

Output:

VahidDM_0-1636588429949.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!


LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Greg_Deckler
Super User
Super User

@Anonymous Maybe:

Measure =
  VAR __Created = MAX('Table'[Created])
  VAR __CreatedDate = DATE(YEAR(__Created),MONTH(__Created),DAY(__Created))
  VAR __MinDate = __CreatedDate + 3/24 + 1/24/60
  VAR __MaxDate = __CreatedDate + 1 + 3/24
  VAR __Min = MINX(FILTER(ALL('Table'),[Created]>=__MinDate && [Created]<=__MaxDate),[Created])
RETURN
  DATE(YEAR(__Min),MONTH(__Min),DAY(__Min))

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Not sure, where is the issue as am not seeing the expected results. 2nd column "Login_Date" is the expected output, while i used the given DAX in 3rd column "Column"

chandrashekarc_0-1636549080273.png

 

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.

Top Solution Authors