Power Query - Change value returned based on two columns and a date used.

bobhasnoidea

New Member
Joined
Apr 9, 2019
Messages
8
I’m only a few weeks in to my Power Query journey and have managed to get a number of complex tasks we do worked out, but I have hit a snag at the last hurdle!
I have a report produced by an external supplier that log the clocking in/out time of staff to numerous sites, this then gets merged with other sheets to record safety incidents etc. so far so good!
The issue I have come across is that I now need to split the name of one site based on the date as we need to separate the record of costs differently.
So in simple language
If [Site] = “Site x” and [In] <13/08/2020 23:59:59 then return “Site xa”
If [Site] = “Site x” and [In] >14/08/2020 00:00:0 then return “Site xb”
If [Site] = “Site A,B,C….,ZZZZ” then return “Site A,B,C….,ZZZ”
Can anyone give me any pointers on how to do this! It has got me stumped!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
maybe
If [Site] = “Site x” and [In] < "13/08/2020 23:59:59" then “Site xa” else If [Site] = “Site x” and [In] >"14/08/2020 00:00:0" then “Site xb” else If [Site] = “Site A,B,C….,ZZZZ” then “Site A,B,C….,ZZZ” else null

I assumed your datetime is a text (value) not a [column]
 
Last edited:
Upvote 0
Thanks Sandy. That got me where I needed to get to!
for any one else i ended up adding a column of pure date not DATETIME and then
if [Site]= "Site x" and [Date]<= #date(2020,8,13) then "Site Xa"
else if [Site]= "Site x" and [Date]>= #date(2020,8,14) then "Site Xb"
else [Site]
Thanks for the guidance.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top