cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chandrashekarc
Helper III
Helper III

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 @chandrashekarc 

 

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 @chandrashekarc 

 

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

@chandrashekarc 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!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

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
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors