Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
raionkar
Regular Visitor

Calculating first and last entry for a particular date from a table

Hi there, 

I am building a time attendance sheet by using data from access server. I have a coloumn in a table where I have all the instances when a employee left or entered the building during a date range.

But I want to get first and last enteries on a particular day. Can anyone help me with achieving that ? 

Capture.JPG

6 REPLIES 6

@amitchandak , thanks for your reply.. I think that's for a record that has mutliple enteries for just one day. In my case, I have a table where I have multiple enteries for a date range..  Please check the picture Capture_1.jpg

 

HI @raionkar ,

You can add a column to the stored date part of EVTime, then write a measure to calculate first/last DateTime based on current date group.  After these steps, you can create a table visual with date as category and measure as detail value to display corresponding records.

EVDate =
DATEVALUE ( Table[EVTime] )

Measure =
VAR current =
    SELECTEDVALUE ( Table[EVTime] )
VAR _min =
    CALCULATE (
        MIN ( Table[EVTime] ),
        FILTER ( ALLSELECTED ( Table ), [EnterArea] = 1 ),
        VALUES ( Table[EVDate] )
    )
VAR _max =
    CALCULATE (
        MAX ( Table[EVTime] ),
        FILTER ( ALLSELECTED ( Table ), [ExitArea] = 1 ),
        VALUES ( Table[EVDate] )
    )
RETURN
    IF ( current IN { _min, _max }, current )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello @v-shex-msft ,

I am getting a syntax error when I type in the forumla for var. I am using PowerBI desktop. 

HI @raionkar ,

Can you please share the detail error message with a snapshot?

BTW, I share two formulas: calculated column and measure, please not use them in the same calculated filed. ('EVDate' is calculated column and 'measure' is measure)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

There is an option. use summarize. There you can take min and max time.

https://docs.microsoft.com/en-us/dax/summarize-function-dax

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.