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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sri_phani
Helper III
Helper III

Get the First activity based on date column

Hi, 

 

I have been trying this for a long time, but I haven't been able to do this.  please help me with this. 

 

Requirement: I have to show agents today's first break period in a Card visual.  
Tables in Dataset - Activeagents, Verint table. 

Relationship: Activeagents to Verint Table (1 to Many). 

Condition - The page has an Employee Name slicer, for the selected employee name, based on shift date filter today's date and filter Break, then based on activity start time first minium value to show the Activity timesbetween(result is like 04:00 PM - 04:15 PM IST)

Here is the sample data of single employee : https://docs.google.com/spreadsheets/d/17wFnZqJb6fDiMZcek_L3k0EipAGssLYRgpGKKMXeXRs/edit?usp=sharing 

(I want the value which is highlighted in Yellow and Red in Card visual)


Here is the DAX code which I am using = 

Firstbreak =
VAR TodayDate = TODAY()
VAR SelectedEmployee = SELECTEDVALUE(ActiveAgentsFiltered[Employee Name])

// Step 1: Filtered Table
VAR Filtered =
    FILTER(
        Verint,
        Verint[Shift Date] >= TodayDate &&
        Verint[Shift Date] < TodayDate + 1 &&
        CONTAINSSTRING(Verint[Activity Name], "Break") &&
        Verint[Employee Name as per IROZ] = SelectedEmployee
    )

// Step 2: Minimum Start Time
VAR MinimumStartTime =
    CALCULATE(
        MIN(Verint[Activity Start time]),
        Filtered
    )

// Step 3: Corresponding Activity Time Between
VAR ActivityTime =
    CALCULATE(
        FIRSTNONBLANK(Verint[Activity Timebetween], 1),
        Verint[Activity Start time] = MinimumStartTime,
        Verint[Employee Name as per IROZ] = SelectedEmployee
    )
// Return the Result
RETURN
ActivityTime

 

Appreciate your help. 

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@Sri_phani Try this. PBIX is attached below signature.

Measure = 
    VAR __Emp = MAX('Table'[Employee Name as per IROZ])
    VAR __Table = FILTER( 'Table', [Extracted Activity Name] = "Break_Unpaid" )
    VAR __MaxBreakStart = MAXX( __Table, [Activity start IST/EET] )
    VAR __MaxBreakEnd = MAXX( FILTER( 'Table', [Activity start IST/EET] = __MaxBreakStart ), [Activity end IST/EET] )
    VAR __BreakStartTime = __MaxBreakStart - TRUNC( __MaxBreakStart )
    VAR __BreakEndTime = __MaxBreakEnd - TRUNC( __MaxBreakEnd )
    VAR __Result = FORMAT(__BreakStartTime, "Medium time" ) & " - " & FORMAT( __MaxBreakEnd, "Medium time" )
RETURN
    __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Rakesh1705
Super User
Super User

hi @Sri_phani ,

 

as per the data available in the mentioned link the minimum time for break on 26th Jul should be 12.45 PM.

Rakesh1705_0-1722239186526.png

After considering this, if I proceed then I have done the following steps

Filter the table with respect to Break_Unpaid

Rakesh1705_2-1722239383010.png

Calculating first break

Rakesh1705_3-1722239422155.png

 

Please check visualization

Rakesh1705_4-1722239535555.png

Now if you need the yellow/red highlighted time as first break then either max function or distinctcount function (if there are more than 2 break periods available for an employee per day) needs to be used.
Using max function

Rakesh1705_5-1722239707884.png

Using Distinctcount function

Rakesh1705_6-1722240433727.png

Visualization can be done in the similar way.

If this solves your problem then accept the same as your solution.

View solution in original post

4 REPLIES 4
Rakesh1705
Super User
Super User

hi @Sri_phani ,

 

as per the data available in the mentioned link the minimum time for break on 26th Jul should be 12.45 PM.

Rakesh1705_0-1722239186526.png

After considering this, if I proceed then I have done the following steps

Filter the table with respect to Break_Unpaid

Rakesh1705_2-1722239383010.png

Calculating first break

Rakesh1705_3-1722239422155.png

 

Please check visualization

Rakesh1705_4-1722239535555.png

Now if you need the yellow/red highlighted time as first break then either max function or distinctcount function (if there are more than 2 break periods available for an employee per day) needs to be used.
Using max function

Rakesh1705_5-1722239707884.png

Using Distinctcount function

Rakesh1705_6-1722240433727.png

Visualization can be done in the similar way.

If this solves your problem then accept the same as your solution.

You solution as well worked for me. Thank you Rakesh.!

@Sri_phani if it works then it is requested you to accept the same as solution. It will be helpful for me too.

Greg_Deckler
Community Champion
Community Champion

@Sri_phani Try this. PBIX is attached below signature.

Measure = 
    VAR __Emp = MAX('Table'[Employee Name as per IROZ])
    VAR __Table = FILTER( 'Table', [Extracted Activity Name] = "Break_Unpaid" )
    VAR __MaxBreakStart = MAXX( __Table, [Activity start IST/EET] )
    VAR __MaxBreakEnd = MAXX( FILTER( 'Table', [Activity start IST/EET] = __MaxBreakStart ), [Activity end IST/EET] )
    VAR __BreakStartTime = __MaxBreakStart - TRUNC( __MaxBreakStart )
    VAR __BreakEndTime = __MaxBreakEnd - TRUNC( __MaxBreakEnd )
    VAR __Result = FORMAT(__BreakStartTime, "Medium time" ) & " - " & FORMAT( __MaxBreakEnd, "Medium time" )
RETURN
    __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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