Forum Discussion

nanma94's avatar
nanma94
Helper III
6 years ago
Solved

Opportunity stage duration

I have an opportunity header table, that stores the latest stage, and I will ultimately want to analyze opportunity cycle time (duration per stage) by owner, territory.    OpportunityId StageNa...
  • parry2k's avatar
    parry2k
    6 years ago

    nanma94 try measure below and here is the result.

     

    Days between Stages = 
    VAR __oppyId = SELECTEDVALUE ( Oppy[OpportunityId] )
    VAR __Stage = MAX ( 'Oppy Detail'[Stage #] )
    VAR __StageDate = MAX ( 'Oppy Detail'[CreatedDate] )
    VAR __prevStage = MAX ( __Stage - 1, 1 )
    VAR __prevStageDate = 
    CALCULATE ( 
        MAX ( 'Oppy Detail'[CreatedDate] ),
        ALL ( 'Oppy Detail' ), 
        Oppy[OpportunityId] = __OppyId, 
        'Oppy Detail'[Stage #] = __prevStage 
    )
    RETURN DATEDIFF( __prevStageDate, __StageDate, DAY )

     

     

    Would appreciate Kudos 🙂 if my solution helped.