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
lifesafari
Helper I
Helper I

Datediff start to end in relationship orderid

Hello, i have this file where i have this info:

 

  • date/time
  • number 
  • orderid 


I need calculate different, for each orderid, from start time (have number 0 on colum number) and end (have mx number for this orderid on column number) in minutes. 


I try to create two colum:

1) Start Date 

DataInizio = IF([Numero] = 0, [Data e ora creazione], BLANK())
 
2) End Date

DataFine = IF([Numero] = MAXX(FILTER(AxTable1, [Nr. Commessa] = EARLIER([Nr. Commessa])), [Numero]), [Data e ora creazione], BLANK())

3) DateDiff

Diff = DATEDIFF(AxTable1[DataFine],AxTable1[DataInizio],MINUTE)

But have blank on column 3 😞 
3 REPLIES 3
v-weiyan1-msft
Community Support
Community Support

Hi @lifesafari ,

 

Can you share sample data and the results you are hoping for? Show it as a screenshot or excel. Or a sample pbix after removing sensitive data. We can better understand the problem and help you.


Best Regards,
Yulia Yan

Sahir_Maharaj
Super User
Super User

Hello @lifesafari,

 

Can you please try this approach:

 

DateDiffMinutes = 
VAR MaxNumberPerOrder = SUMMARIZE(YourTable, YourTable[orderid], "MaxNum", MAX(YourTable[number]))
VAR StartDate = MINX(FILTER(YourTable, YourTable[Numero] = 0), YourTable[Data e ora creazione])
VAR EndDate = MAXX(FILTER(YourTable, YourTable[orderid] IN SELECTCOLUMNS(MaxNumberPerOrder, "OrderID", YourTable[orderid]) && YourTable[Numero] = [MaxNum]), YourTable[Data e ora creazione])
RETURN
DATEDIFF(StartDate, EndDate, MINUTE)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hello this not working. 

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.