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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
stan255tf
Regular Visitor

Calculating difference in two fields from the same column

We have a list of opportunities with stages and each stage has a date associated with it based on when it was last updated. In PowerQuery, the stages are all in one column and the dates are all in one column.

 

How do you calculate the date difference between the two stages (New and Closed Won) when both of them are in the same column?

 

Note: Attaching both the PowerBI table (filtered to show only New and Closed Won stages) and the PowerQuery for reference.

 

stan255tf_0-1690843202805.png

stan255tf_1-1690843237296.png

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @stan255tf 

 

Based on the data you provided, you can try the following.

Measure:

New Date = CALCULATE(MAX('Table'[CreatedDate]),FILTER(ALL('Table'),[StageName]="1. New"&&[ID]=SELECTEDVALUE('Table'[ID])))
Closed Lost Date = CALCULATE(MAX('Table'[CreatedDate]),FILTER(ALL('Table'),[StageName]="8. Cloesd Lost"&&[ID]=SELECTEDVALUE('Table'[ID])))
Difference = DATEDIFF([New Date],[Closed Lost Date],DAY)

vzhangti_0-1690956914976.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @stan255tf 

 

Based on the data you provided, you can try the following.

Measure:

New Date = CALCULATE(MAX('Table'[CreatedDate]),FILTER(ALL('Table'),[StageName]="1. New"&&[ID]=SELECTEDVALUE('Table'[ID])))
Closed Lost Date = CALCULATE(MAX('Table'[CreatedDate]),FILTER(ALL('Table'),[StageName]="8. Cloesd Lost"&&[ID]=SELECTEDVALUE('Table'[ID])))
Difference = DATEDIFF([New Date],[Closed Lost Date],DAY)

vzhangti_0-1690956914976.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-zhangti, this worked.

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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