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
souhail98
Frequent Visitor

Row data in chronological order

Hi, 

 

The table below is my datasource, every row is an activity within the Transport ride (1st column left) . I dont know how to convert the vertical data to horizontal in a chronological order (start, load, unload, end) based on time.

 

Ride header activity id activity name Timezip code, etc
313790180978start06:004844
313790180979Load06:154844
313790180980unload13:155001
313790180981end 17:004844

 

I want to make a table visual with calcultated (duration) columns, something like this below: 

Ride headerStartloadDuration load timeZipcode unload

Duration 

Drive and unload time 

Zipcodeend Duration drive back time Total time 
31379006:0006:1515 min484413:157 hours500117:003:4511 hours

 

I hope it is understandable.

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @souhail98 ,

I created a sample pbix file (see attachment) base on provided data, please check whether that is what you want.

1. Create a Sort table

2. Create a measure as below to get the duration

Duration = 
VAR _curtime =
    SELECTEDVALUE ( 'Table'[Time] )
VAR _preaid =
    CALCULATE (
        MAX ( 'Table'[activity id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Ride header] = SELECTEDVALUE ( 'Table'[Ride header] )
                && 'Table'[Time] < _curtime
        )
    )
VAR _pretime =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[activity id] = _preaid )
    )
VAR _duration =
    DATEDIFF ( _pretime, _curtime, SECOND ) //var _day= INT(_duration/(24*60*60))
VAR _hour =
    MOD ( INT ( _duration / ( 60 * 60 ) ), 24 )
VAR _minute =
    MOD ( INT ( _duration / 60 ), 60 )
VAR _second =
    MOD ( _duration, 60 )
RETURN
    //if(_day=0,BLANK(),_day&"day(s) ")&
    IF (
        _hour = 0,
        BLANK (),
        _hour & "hour(s) "
    )
        & IF ( _minute = 0, BLANK (), _minute & "minute(s) " )
        & IF ( _second = 0, BLANK (), _second & "second(s) " )

3. Put the field activity name of Sort table(Sort by column: Order ) , field Ride header and measure onto matrix

Sort a Column with a Custom Order in Power BI

yingyinr_0-1615428093936.png

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @souhail98 ,

I created a sample pbix file (see attachment) base on provided data, please check whether that is what you want.

1. Create a Sort table

2. Create a measure as below to get the duration

Duration = 
VAR _curtime =
    SELECTEDVALUE ( 'Table'[Time] )
VAR _preaid =
    CALCULATE (
        MAX ( 'Table'[activity id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Ride header] = SELECTEDVALUE ( 'Table'[Ride header] )
                && 'Table'[Time] < _curtime
        )
    )
VAR _pretime =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[activity id] = _preaid )
    )
VAR _duration =
    DATEDIFF ( _pretime, _curtime, SECOND ) //var _day= INT(_duration/(24*60*60))
VAR _hour =
    MOD ( INT ( _duration / ( 60 * 60 ) ), 24 )
VAR _minute =
    MOD ( INT ( _duration / 60 ), 60 )
VAR _second =
    MOD ( _duration, 60 )
RETURN
    //if(_day=0,BLANK(),_day&"day(s) ")&
    IF (
        _hour = 0,
        BLANK (),
        _hour & "hour(s) "
    )
        & IF ( _minute = 0, BLANK (), _minute & "minute(s) " )
        & IF ( _second = 0, BLANK (), _second & "second(s) " )

3. Put the field activity name of Sort table(Sort by column: Order ) , field Ride header and measure onto matrix

Sort a Column with a Custom Order in Power BI

yingyinr_0-1615428093936.png

Best Regards

Hi @Anonymous 

 

Thank you very much! The activities needed to be on chronological order based on time.  The example below shows multiple activities within one ''rit header''. The activities are performed interchangeably within the process. Is it possible to make a dynamic process timeline?

multiple times.PNG

 

 

 

 

 

 

 

 

 

 

 

 

Best regards,

Souhail

Anonymous
Not applicable

Hi @souhail98 ,

In this case, there is no need to create another Sort dimension table. First select field activity name, and then navigate to Column tools ribbon and click Sort by column to select Time field.

yingyinr_0-1615527487943.png

Best Regards

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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
Top Kudoed Authors