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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dresinger
Frequent Visitor

Creating a measure based on filters from other columns

Appologies from the jump as I am new to Power BI.

 

I am trying to create a measure or column that will pull data from other rows in my data table.  This is what I currently have, how my data is structured and what I am looking to get:

 

I have a table that tracks "memos" entered into a system in chronological order.  These "memos" are given a sequential, unique ID by the system and also time stamped.  Table is structured like this:

 

memo_idtimepointmessage
11622815423Drill Started
21622815596Drill Stopped
31622815620Drill Started
41622816021Drill Stopped

 

I added a calculated column to convert timepoint (unix time) to date/time and now have this:

memo_idtimepointmessagedate/time
11622815423Drill Started6/4/2021 2:03:43PM
21622818287Drill Stopped6/4/2021 2:51:27PM
31622818331Drill Started6/4/2021 2:52:11PM
41622820922Drill Stopped6/4/2021 3:35:22PM

 

What I need to so is add 3 columns that signify the start, stop and duration of a drill.  I already added the start time by using this formula in a measure:   

Drill Start Date/Time = if(CONTAINSSTRING('memos_view'[message],"drill started")=TRUE(),'memos_view'[Date/Time])
 
 
I now need to look for the next "drill stopped" message and copy that date/time to the same row and also calculate the duration.  My desired table should look like this:
 
memo_idtimepointmessagedate/timeDrill StartedDrill StoppedDuration
11622815423Drill Started6/4/2021 2:03:43PM6/4/2021 2:03:43PM6/4/2021 2:51:27PM0:0:47:44
21622818287Drill Stopped6/4/2021 2:51:27PM   
31622818331Drill Started6/4/2021 2:52:11PM6/4/2021 2:52:11PM6/4/2021 3:35:22PM0:0:43:11
41622820922Drill Stopped6/4/2021 3:35:22PM   

 

Any help is appreciated!!!

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @dresinger,

Any update for these? Did these suggestions help with your situation? If that is the case, you can consider Kudo or accept it to help others who have the same requirement.
If the above does not help, please share more detailed information to help us clarify this scenario.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

HI @dresinger,

You can use the following calculated column expression to get the next stop DateTime based on the current DateTime.
After these steps, you can create a new column with 'datediff' function to calculate the diff between two DateTime fields.

Drill Stopped =
MINX (
    FILTER (
        Table,
        [date/time] > EARLIER ( Table[date/time] )
            && [message] <> "Drill Started"
    ),
    [date/time]
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.