cancel
Showing results for
Did you mean:
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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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")

Highlighted
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")

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 65 members 1,176 guests
Recent signins: