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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SMITHY10283
Regular Visitor

Create calculated column

Hi, I need help in creating a calculated column and don't know where to start. 

 

So I have a dataset with Portfolio, Project, Reporting Date, Status as columns. 

 

PortfolioProjectReporting DateStatusTime to Completed
DataAAAA01 Apr 2022Started0
DataAAAA01 May 2022Completed1
DataAAAA01 June 2022On track0
DataAAAA01 July 2022Completed1
DataBBBB01 Apr 2022Completed0
DataBBBB01 May 2022Started0
DataBBBB01 June 2022Completed1
DataBBBB01 July 2022Completed

0

 

DivisonCCCC01 Apr 2022Completed0
DivisonCCCC01 May 2022Started0
DivisonCCCC01 June 2022Started0
DivisonCCCC01 July 2022Completed

2

 

 

What I want to calculate is the Time to Completed column (expected output in red), which is how long it took the status to turn to Completed. For example for the first project, it went from started to completed after 1 month in May and July, and for the second project it went Completed after 1 month in June, and similarly it took 2 months for the status to go to Green for the 3rd project. 

For the second project, since the month after (July) was also "Completed", the Time to Completed remains at 0. 
Also for the month in Apr in the same project the status is "Completed" but since that is the first entry that is recorded, there is no other Completed status to compare to hence why it is 0. 

How would I do this?

1 REPLY 1
amitchandak
Super User
Super User

@SMITHY10283 , Try meausre like , and find the file attcahed

 

Progress1 = 
var _min = Maxx(filter(Projects, Projects[project] = earlier(Projects[Project]) && Projects[Status] = "Completed" && [Reporting Date] < earlier([Reporting Date])) , [Reporting Date])
var _min1 = if(ISBLANK(_min) , minx(filter(Projects, Projects[project] = earlier(Projects[Project])  && [Reporting Date] < earlier([Reporting Date])) , [Reporting Date]) , minx(filter(Projects, Projects[project] = earlier(Projects[Project])  && [Reporting Date] >_min && [Reporting Date] < earlier([Reporting Date])) , [Reporting Date]))
return
if(Projects[Status] = "Completed", DATEDIFF(_min1, [Reporting Date], MONTH),0
)
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors