cancel
Showing results for 
Search instead for 
Did you mean: 
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
v-jayw-msft
Community Support
Community Support

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

 

 

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

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

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

 

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
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
Super User
Super User

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


@ 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!:
Mastering Power BI 2nd Edition

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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors