cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
WillemUK Frequent Visitor
Frequent Visitor

If condition between two times

I am trying to use an if statement to determine type of wastage created between two tim frames.

 

The idea is that between 14:30 and midnight the wastage is labelled as "End of Day Wastage" and the rest of the time it is labelled as just "Wastage".

 

The date and time column is formatted like this "DDMMYYYY HHMMSS"

 

This is the formula I am using but it doesnt work. It displays everything as "Wastage".

Wastage Type = IF(AND(Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) > Time(16,30,00), Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) <= Time(00,00,00)), "End of Day Wastage", "Wastage")

 

I am guessing it is probably something wrong with my logic but just can't see it.

 

Can anyone help, please?

1 ACCEPTED SOLUTION

Accepted Solutions
WillemUK Frequent Visitor
Frequent Visitor

Re: If condition between two times

No worries i solved it.

 

The automatic cutoff time was 59:59:59 so at 00:00:00 the calculation returned back to "Wasted".

 

I removed the AND() and Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) <= Time(00,00,00)) from the formula.

 

Here is the working code:

Wastage Type = IF(Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) > Time(16,30,00), "End of Day Wastage", "Wastage")

View solution in original post

1 REPLY 1
WillemUK Frequent Visitor
Frequent Visitor

Re: If condition between two times

No worries i solved it.

 

The automatic cutoff time was 59:59:59 so at 00:00:00 the calculation returned back to "Wasted".

 

I removed the AND() and Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) <= Time(00,00,00)) from the formula.

 

Here is the working code:

Wastage Type = IF(Time(Hour(Wastage[Transaction Date]),minute(Wastage[Transaction Date]),SECOND(Wastage[Transaction Date])) > Time(16,30,00), "End of Day Wastage", "Wastage")

View solution in original post

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 306 members 3,266 guests
Please welcome our newest community members: