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

Complex DAX Operation

Hi, I have a live streaming dataset in power bi. The data transformation feature, Add new coloumn and create new table all of this features are disabled for live streaming data. The operation that i want to perform is like that : I have four coloumns in my dataset 1. PlatformId, 2. DateTime, 3. Tag, 4 Value. Now there is a pattern in my data. where the values of Tag are In, Work, EndStart, EndClose and Out sequentially, for this all five records platformId is same and datatime values are in ascending order. next five records are for another platform, then for next platform, then for next platform. I have total 5 platforms. After 5th platform it again starts from first platform and goes till 5th platform, again start from first platform..... and so on. Now i want to find out the difference between In DateTime and Out DateTime, Difference between Work DateTime and EndStart DateTime, Difference between EndStart DateTime and EndClose DateTime. How Can i do it. I dont have index coloumn in my dataset?

 

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @GovindPrajapat,

 

Since you don't have an index column and the data transformation features are disabled for live streaming data, you can achieve your desired calculations using DAX measures instead.

 

1. Create Measures

 

1.1. Difference between In DateTime and Out DateTime

In_Out_Difference = 
VAR CurrentDateTime = MIN('YourTable'[DateTime])
VAR NextDateTime = CALCULATE(MIN('YourTable'[DateTime]), 'YourTable'[DateTime] > CurrentDateTime, 'YourTable'[Tag] = "Out", 'YourTable'[PlatformId] = EARLIER('YourTable'[PlatformId]))
RETURN
IF('YourTable'[Tag] = "In" && NOT(ISBLANK(NextDateTime)), NextDateTime - CurrentDateTime)

1.2. Difference between Work DateTime and EndStart DateTime

Work_EndStart_Difference = 
VAR CurrentDateTime = MIN('YourTable'[DateTime])
VAR NextDateTime = CALCULATE(MIN('YourTable'[DateTime]), 'YourTable'[DateTime] > CurrentDateTime, 'YourTable'[Tag] = "EndStart", 'YourTable'[PlatformId] = EARLIER('YourTable'[PlatformId]))
RETURN
IF('YourTable'[Tag] = "Work" && NOT(ISBLANK(NextDateTime)), NextDateTime - CurrentDateTime)

1.3. Difference between EndStart DateTime and EndClose DateTime

EndStart_EndClose_Difference = 
VAR CurrentDateTime = MIN('YourTable'[DateTime])
VAR NextDateTime = CALCULATE(MIN('YourTable'[DateTime]), 'YourTable'[DateTime] > CurrentDateTime, 'YourTable'[Tag] = "EndClose", 'YourTable'[PlatformId] = EARLIER('YourTable'[PlatformId]))
RETURN
IF('YourTable'[Tag] = "EndStart" && NOT(ISBLANK(NextDateTime)), NextDateTime - CurrentDateTime)

2. Create visuals using these measures to display the time differences for each platform based on the "Tag" values.

 

Should you require further assistance please do not hesitate to reach out to me.


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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.