Forum Discussion

rjsidek's avatar
rjsidek
Helper II
6 years ago
Solved

Getting Date Difference between Stages in the same column

Hi everyone,   I currently have a sample dataset that looks like this:   What I am trying to achieve is this:   I am looking to create a measure that tells me how long it takes for the "P...
  • az38's avatar
    az38
    6 years ago

    rjsidek 

    how it should look if no one slicer is chosen?

    anyway, try a measure

    Measure = 
    var SecondStage = 
    calculate(min('Table1'[Date]);ALLEXCEPT('Table1';'Table1'[Company];Table1[Stage]))
    var Init = calculate(max('Table1'[Stage]);ALLEXCEPT('Table1';'Table1'[Company]);'Table1'[Date]<SecondStage;'Table1'[Stage]<>"")
    var InitialStage = if(isblank(Init);SecondStage;calculate(min('Table1'[Date]);FILTER(ALL('Table1');'Table1'[Company]=SELECTEDVALUE(Table1[Company])&&'Table1'[Stage]=Init)))
    RETURN
    DATEDIFF(InitialStage; SecondStage; DAY)

    do not hesitate to give a kudo to useful posts and mark solutions as solution