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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
icassiem
Post Prodigy
Post Prodigy

Calculating Sales Velocity Avg day duration per process and per stage

Good day,

 

This is a tough one, and I am not following., Calculating Sales Velocity Avg day duration per process and per stage

 

I first, calculate the duration between each opportunity stage min and max date with:

HistoryDate_DurationDayActual = if(ABS(DATEDIFF('SalesForce_SalesStageVelocityActual'[HistoryCreatedDateMin],SalesForce_SalesStageVelocityActual[HistoryModifiedClosingDateMax].[Date],DAY))=0,1, ABS(DATEDIFF('SalesForce_SalesStageVelocityActual'[HistoryCreatedDateMin],SalesForce_SalesStageVelocityActual[HistoryModifiedClosingDateMax].[Date],DAY)))

 

now i am trying to average the duration based off the number of opportunities to give the avg opportunity process that includes 5 stages:

ActualDurationAVG =
VAR SelectedStartDate = CALCULATE(MIN(Calc_SpecialDates[Date]), filter(ALL(Calc_SpecialDates),Calc_SpecialDates[Period] = "FYTD"))
VAR SelectedEndDate = CALCULATE(MAX(Calc_SpecialDates[Date]), filter(ALL(Calc_SpecialDates),Calc_SpecialDates[Period] = "FYTD"))
//calc col
VAR StageDuration = calculate(sum(SalesForce_SalesStageVelocityActual[HistoryDate_DurationDayActual]),SalesForce_SalesStageVelocityActual[HistoryCreatedDateMin] >= SelectedStartDate,
SalesForce_SalesStageVelocityActual[HistoryCreatedDateMin] <= SelectedEndDate)

VAR MonthCount =
CALCULATE(
DISTINCTCOUNT(SalesForce_SalesStageVelocityActual[OpportunityID]),
SalesForce_SalesStageVelocityActual[HistoryCreatedDateMin] >= SelectedStartDate,
SalesForce_SalesStageVelocityActual[HistoryCreatedDateMin] <= SelectedEndDate)

RETURN
    DIVIDE(StageDuration, MonthCount)
 
i am not feeling comfortable this is accurate and i need a second calcated measure to give me the AVG  Duration per Stage accross all opportunites
 

Please help, i am lost

Regards
1 ACCEPTED SOLUTION

There are many ways to interpret that.  And even opportunities marked as "Closed, gone away"  are not always really dead - they can be revived and go back to a prior state.

 

lbendlin_0-1753800952878.png

 

You can only calculate this if you have more than one event per opportunity, or if you assume that the last stage extends until "Today".

 

lbendlin_1-1753801211246.png

 

Technically "c" should be "c-1" - but that's up for debate too.

 

View solution in original post

10 REPLIES 10
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

@lbendlin  Thank you for assisting

Attached is my sample dataset anonymised 

i am trying to get my average day which is the calc column that gives me the day dureation and then average by opportunity, and then i want to avg per stage. the structure is the an opportunity contains multiple stages

Please help me

icassiem_0-1753704828341.png

 



OpportunityIDOpportunityNameOpportunityHistoriesStageNameHistoryCreatedDateMinHistoryModifiedClosingDateMax
0064**********GQAYGen****************************************************port (WS1)Closed Gone Away2025/05/292025/05/29
0064**********GQAYGen****************************************************port (WS1)Stalled2023/08/052025/05/29
0064**********KQAWAmc******************************************** (ACC LWA)Closed Gone Away2025/05/162025/05/16
0064**********KQAWAmc******************************************** (ACC LWA)Stalled2023/11/292025/05/16
0064**********GQAQSup************************pportunityNDA not Executed2023/11/072023/11/07
0064**********ZQAZ#VALUE!Stalled2024/01/232024/01/23
0064**********cQADAB ******************id ResultsClosed Gone Away2025/01/222025/01/22
0064**********UQA1Ime****erys (WS1)Stalled2023/11/142023/12/07
0064**********qQAJSNF********S/C TRACCSClosed Gone Away2024/01/122024/01/12
0064**********qQAJSNF********S/C TRACCSStalled2023/12/072024/01/12
0064**********BQARon-***************************F interestClosed Gone Away2023/11/072023/11/07
0064**********RQA3Fin**********************ills (WS1)Won/Closed2023/08/102023/08/10
0064**********RQA3Fin**********************ills (WS1)Legal Negotiation2023/07/202023/08/10
0064**********RQA3Fin**********************ills (WS1)Contract Negotiations2023/06/262023/07/20
0064**********6QAPYie************************EMENTATIONClosed Gone Away2025/01/222025/01/22
0064**********hQAJDou********************************************ing - MAKEStalled2024/06/232025/07/11
0064**********hQAJDou********************************************ing - MAKEProposal Evaluation2023/08/052024/06/03
0064**********hQAJDou********************************************ing - MAKEContract Negotiations2023/08/072023/08/24
0064**********hQAJDou********************************************ing - MAKEDesign2023/06/262023/08/05
0064**********nQAJGra************************************TRACC MakeClosed Gone Away2024/10/032024/10/03
0064**********nQAJGra************************************TRACC MakeStalled2024/06/182024/10/03
0064**********qQAFDou*********Good-  NDAExecuted NDA2023/06/212023/06/21

@lbendlin 

Hi, any help, please?

There are many ways to interpret that.  And even opportunities marked as "Closed, gone away"  are not always really dead - they can be revived and go back to a prior state.

 

lbendlin_0-1753800952878.png

 

You can only calculate this if you have more than one event per opportunity, or if you assume that the last stage extends until "Today".

 

lbendlin_1-1753801211246.png

 

Technically "c" should be "c-1" - but that's up for debate too.

 

@lbendlin hi, i am lost

 

Would this give me avg day duratuon per stage, then avg day for  opportunity cycle, then the avg stage day dur?

 

An opportunity has 5 to 6 stages witjin a cycle, but nit all opportubities ends at variois stages witjin a opp cycle.

 

1. So the avg  no of day per stage i want to put in a horizontal line bar

2. The avg opportunity no of days, meaning on avg how long sn ppportubity takes

3..The avg stage no of days, meaning on avg how long a stage takes

 

 

Could it be done?

Do you only want to include "past"  stages (ie stages that have been superseded) or do you also want to include "current"  stages without an end date?

@lbendlin 

My scorecard is filtered on all opportunities stages started/initiated within a FY year (Jun to May), with the HistoryCreatedDateMin being the key date to calendar and filter range

 

so if the stage or opportuntity still open, use the current date to ensure it is included in calculations
i would like these 3 measures

1. So the avg  no of day per stage i want to put in a horizontal line bar

2. The avg opportunity no of days, meaning on avg how long sn ppportubity takes

3..The avg stage no of days, meaning on avg how long a stage takes

what's the difference between1 and 3?

@lbendlin  , Hi, the difference, 1 is the avg per stage, 3 is the avg day dur a stage takes within an opportunity takes

4. But now I need to calculate the variance between yoy, which is 1 and 2 vs yoy, does this mean I replicate what we do for 1 and 2 actuals then calculate the variance to history ?

@lbendlin thank you, all good

I had to make copies of the dataset in various granularities 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.