cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Brianoreilly Regular Visitor
Regular Visitor

If Statement using Calculated Measure and Date Sliceer

Hi Folks,

 

I need to build 2 dynamic measures which will allow me to assess if an employee was/is working within a time period. 

The time period in questions, being dictated by the Min & Max Date of a slicer. 

 

I have two tables. 

A Timecard table with the Dataset and a Date Table for the slicer. 

I do not want to relate. 

 

On the Timecard table there are employee records with columns of start and end date. 

If Finish Date is blank, it means they are still employees. 

 

I need a nested if measuse using the Slicer Max And Min Dates. Once I get one example of the "IF" pulling the max and min values from the slicer into the measure, I should be able to work out all the scenarios. 

 

I basically need 2 measures, call "Start Date" and "End Date", that works out for instance:

If the Employee start date is before the Slicer Min Date and the Employee End Date is blank.

Then the Start Date is the Slicer Min and the End Date is the Slicer Max Date. 

 

Any help would be appreciated. 

 

Start Date - Finish Date.JPG

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: If Statement using Calculated Measure and Date Sliceer

Hi @Brianoreilly,

 

We can create the measures as below to achieve your goal.

 

Start Date =
VAR mindate =
    MIN ( 'date'[Date] )
RETURN
    IF (
        ISBLANK ( MAX ( 'dataset'[Employee End Date] ) )
            && MAX ( 'dataset'[Employee Start Date] ) < mindate,
        mindate,
        MAX ( 'dataset'[Employee Start Date] )
    )
End Date = 
VAR maxdate =
    MAX ( 'date'[Date] )
VAR mindate =
    MIN ( 'date'[Date] )
RETURN
    IF (
        ISBLANK ( MAX ( 'dataset'[Employee End Date] ) )
            && mindate >= MAX ( 'dataset'[Employee Start Date] ),
        maxdate
    )

Capture.PNG

 

Also please find the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: If Statement using Calculated Measure and Date Sliceer

Hi @Brianoreilly,

 

We can create the measures as below to achieve your goal.

 

Start Date =
VAR mindate =
    MIN ( 'date'[Date] )
RETURN
    IF (
        ISBLANK ( MAX ( 'dataset'[Employee End Date] ) )
            && MAX ( 'dataset'[Employee Start Date] ) < mindate,
        mindate,
        MAX ( 'dataset'[Employee Start Date] )
    )
End Date = 
VAR maxdate =
    MAX ( 'date'[Date] )
VAR mindate =
    MIN ( 'date'[Date] )
RETURN
    IF (
        ISBLANK ( MAX ( 'dataset'[Employee End Date] ) )
            && mindate >= MAX ( 'dataset'[Employee Start Date] ),
        maxdate
    )

Capture.PNG

 

Also please find the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

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

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

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.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

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

Users Online
Currently online: 132 members 1,536 guests
Please welcome our newest community members: