Forum

Conditional Column ...
 
Notifications
Clear all

Conditional Column or Custom Column

4 Posts
2 Users
0 Reactions
55 Views
(@raffrobb)
Posts: 38
Trusted Member
Topic starter
 

I am getting an error when I try to build out a conditional column to provide a time based on day.

For example, if day of week equals 0 (Sunday) or 6 (Saturday) make time 8:00 PM, otherwise 2-5 make time 10:00 PM

the column returns the literal #time(22,0,0)

Driving me crazy, can you help figure out the issue?

 

Thanks

Robb

 
Posted : 23/09/2020 12:55 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Robb,

Please provide a sample Excel file showing what you're trying to do so we can reproduce the issue and better understand and help you.

Mynda

 
Posted : 23/09/2020 2:10 am
(@raffrobb)
Posts: 38
Trusted Member
Topic starter
 

Hi Mynda

 

see Store Close error

if day = 0 then 8:00 PM

if day = 6 then 8:00 PM

all other days 2-5 then 10:00 PM

Not sure how conditional column should work in this case.

Thanks

 
Posted : 23/09/2020 8:46 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Robb,

Thanks for the file. Click on the last step in the query editor > go to the formula bar and remove the double quotes around the #time(... formulas, so that it looks like this:

= Table.AddColumn(#"Changed Type1", "store close", each if [In Day of Week] = 6 then #time(20, 0, 0) else if [In Day of Week] = 0 then #time(20, 0, 0) else #time(22, 0, 0))

 

Then change the data type to Time.

Mynda

 
Posted : 23/09/2020 9:11 pm
Share: