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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
datanau001
Helper III
Helper III

Power BI Desktop - Calculate datediff with information from same column

Hello all,
I want to make the datediff with the information from column “change_date_time”.
In this column, for each “pair” of lines, I have the time stamp for status queued and time stamp for status accepted.
But here I’m not sure about the approach to make this calculation since the information is in lines and not in columns. See below:
datediff.png


 

 

 

 

 

 

 

 

I tried with duplicating the table and then work with filters and a new measure, however, it does not seem to be a good approach in my case.
Which would be your suggestion? I mean, to handle this calculation in just one table.
Regards
Marcelo

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@datanau001 

You can Pivot the Status Column on the Change Date Time field then add a new field to calculate the difference.

Select the Status Column, under Transform Tab, click Pivot Column, 
Under the Value column, Select Change-Date-Time column, Select No Aggregation under Advanced Option.
now you get two columns ACCEPTED and  QUEUED. select those columns, under Add Columns Tab, select  Time and Subtract.
You will get a new column with the time difference.

If you find any difficulties, post a sample data with your reply to demonstrate.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Hi, @datanau001 , 

IMHP, there's no point duplicating the dataset for such a calculation. In-line filters can easily do the trick, for example, for a certain SR_NUMBER,

Diff =
CALCULATE ( MAX ( SYSLOG[CHANGE_DATE_TIME] ), SYSLOG[DWH_STATUS] = "Accepted" )
    - CALCULATE ( MAX ( SYSLOG[CHANGE_DATE_TIME] ), SYSLOG[DWH_STATUS] = "Queued" )

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Fowmy
Super User
Super User

@datanau001 

You can Pivot the Status Column on the Change Date Time field then add a new field to calculate the difference.

Select the Status Column, under Transform Tab, click Pivot Column, 
Under the Value column, Select Change-Date-Time column, Select No Aggregation under Advanced Option.
now you get two columns ACCEPTED and  QUEUED. select those columns, under Add Columns Tab, select  Time and Subtract.
You will get a new column with the time difference.

If you find any difficulties, post a sample data with your reply to demonstrate.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy, exaclty what I was looking for.

Thank you!

 

Marcelo

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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