Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Extract duration from start and end date if certain column condition are the same

Solved.
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  Anonymous ,

    I created some data:

     

    Here are the steps you can follow:

    1. Create calculated column.

    Column =
    var _groupmindate=
    MINX(FILTER(ALL('Table'),'Table'[condition]=EARLIER('Table'[condition])),[start date])
    var _groupmaxdate=
    MAXX(FILTER(ALL('Table'),'Table'[condition]=EARLIER('Table'[condition])),[end date])
    var _Seconds=DATEDIFF(_groupmindate,_groupmaxdate,SECOND)
    var _DAXDay= INT(_Seconds/(24*60*60))
    var _DAXHours = MOD(INT(_Seconds/(60*60)),24)
    var _DAXMin   = MOD(INT(_Seconds/60),60)
    var _DAXSec   = MOD(_Seconds,60)
    return
    _DAXDay&" Days & "&
    _DAXHours&" Hours & "&
    _DAXMin&" Minutes & "&
    _DAXSec& " Seconds"

    2. Result:

     

    If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

     

    Best Regards,

    Liu Yang

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