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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Super User
Super User

Please refer

 

https://community.powerbi.com/t5/Desktop/Get-First-and-Last-Values-from-Table/td-p/80219

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@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

 

Anonymous
Not applicable

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

Hello @Anonymous ,

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

Anonymous
Not applicable

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

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

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

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors