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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
➤ About: https://sahirmaharaj.com/about.html
➤ 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.