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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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?
➤ 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.