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
mmcarthur
Frequent Visitor

Group a minimum Datetime by Day and Technician

I am trying to group the minimum arrivedOn datetime by both day and technician using Power BI. Here is an example of my table: 

mmcarthur_0-1668634189821.png

I am tasked with finding when a technician arrived on their first job grouped by each day. It seems to me that I would need to first group the minimum arrivedOn datetime by each Technician. And then group that measure by each day. However, everytime I try this it refuses to work. 

Here is what I am trying to achieve:

mmcarthur_1-1668634515444.png

Any help especially some correct Dax formulas would be very much appreciated.

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mmcarthur ,

 

Create a new table like below:

Table 2 = 
var tmp1 = ADDCOLUMNS('Table',"date",DATEVALUE('Table'[scheduled start]))
var tmp2 = SUMMARIZE(tmp1,[date],'Table'[technician],"job number",MIN('Table'[job number]),"arrived on",MIN('Table'[arrived on]),"scheduled start",MIN('Table'[scheduled start]))
var tmp3 = ADDCOLUMNS(tmp2,"arrived - schedualed",DATEDIFF([scheduled start],[arrived on],MINUTE))
var tmp4 = ADDCOLUMNS(tmp3,"islate",IF([arrived - schedualed]>0,1,0))
return
tmp4

vjaywmsft_0-1669969907236.png

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @mmcarthur ,

 

Create a new table like below:

Table 2 = 
var tmp1 = ADDCOLUMNS('Table',"date",DATEVALUE('Table'[scheduled start]))
var tmp2 = SUMMARIZE(tmp1,[date],'Table'[technician],"job number",MIN('Table'[job number]),"arrived on",MIN('Table'[arrived on]),"scheduled start",MIN('Table'[scheduled start]))
var tmp3 = ADDCOLUMNS(tmp2,"arrived - schedualed",DATEDIFF([scheduled start],[arrived on],MINUTE))
var tmp4 = ADDCOLUMNS(tmp3,"islate",IF([arrived - schedualed]>0,1,0))
return
tmp4

vjaywmsft_0-1669969907236.png

 

 

mmcarthur
Frequent Visitor

@Greg_Deckler I'm sorry I forgot to @ you before!

Supposing you have a Date column in your table named TableName, try to create a table with the code below,
 Table =
VAR Table1= 
    SUMMARIZE(
        TableName,
        TableName[Date]
        TableName[Technician],
    )
VAR Table2=
    ADDCOLUMNS(
        Table1,
        "Min Arrived On",
        CALCULATE( MIN( TableName[Arrived On] ) )
    )
VAR Table3 =
    ADDCOLUMNS(
        Table2,
        "Job Number",
        CALCULATE( MIN(TableName[Job Number])),
        "Scheduled Start",
        CALCULATE( MIN(TableName[Schduled Start]))
)
RETURN 
    Table3
 
would sugget you to provide some copiable and simplified data, so at least we can verify the code for you.
mmcarthur
Frequent Visitor

The measure I am trying to get for this is the number first jobs for each day worked for all technicians that were late divided by the total number of first jobs for each day worked for all technicians. 

Greg_Deckler
Community Champion
Community Champion

@mmcarthur Can you just put Date, Technician in a Table visual and use MIN('Table'[Arrived On]) ?



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...

That is not gonna work for what I'm needing. I'm needing to create measures based on the grouping so I would need to know how to make sure DAX is taking the minimum arrived on time for each day for each technician.

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.