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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Time for item to reach certain status

Good afternoon!

 

I am trying to find a solution for below issue. I have 3 columns of data: date/time; Item and status. I would like to have a duration calculated in a query in the 4th column.

 

Every item starts with status ACK/UNACK, I would like to know for every item in the list how long it takes to reach status ACT/ACK. See below example of D43FC120, it took 3 minutes and 25 seconds to reach the status ACT/ACK. An item can occur more than once in the table so the function should only calculate the duration based on the first ACT/ACK it comes across in the table. If an item does not reach ACT/ACK it should display "no change".

 

Hope somebody can help, have been puzzling for a while now for a solution but not succesful yet.

 

If more info is needed please let me know!

 

Best regards,

Lucmev

 

DateItemStatusTime to ACK
1/1/2020 1:35:28 PMD24LS303INACT/UNACK 
1/1/2020 1:35:29 PMD24EC331INACT/UNACK 
1/1/2020 1:43:06 PMD43FC120ACT/UNACK00:03:25
1/1/2020 1:43:32 PMD43FC110INACT/ACK 
1/1/2020 1:46:31 PMD43FC120ACT/ACK 
1/1/2020 1:48:22 AMD44LS102ACT/ACK 
1/1/2020 1:48:26 AMD44LS102INACT/ACK 
1/1/2020 1:49:41 PMD24LS303ACT/UNACK 
1/1/2020 1:49:42 PMD24EC331ACT/UNACK 

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you may want to try a PQ solution as follows,

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdA9CsMwDAXgqxjPAUtPrkm0BbeB0B8KbaeQ+1+jgpYQsONFaPiekLQsngMHEMixyknRu+fdd/6MeHsJibXzY8zv8LF69WtXBIYtcMki3A5EUUr/QJQpM8jaFhfsOdM2v8aTClen13CvgBt/2I5lQhunAh8vMmjk4pHHZxpH8cYdX78=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Item = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Item", type text}, {"Status", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Time to ACK",
        each
            if [Status] <> "ACT/UNACK" then ""
            else
                [
                    grouped = Table.Group(#"Changed Type", {"Item"}, {{"Time to ACK", each _}}){[Item = [Item]]}[#"Time to ACK"],
                    end = try grouped{[Status="ACT/ACK"]}[Date] otherwise null,
                    dur = end - [Date] ?? ""
                ][dur]
    )
in
    #"Added Custom"

 

 

Screenshot 2020-10-10 175243.png

Measure and calculated column solutions are also available, for fun😁

You may want to refer to the attach file for more details.

Measure:

Screenshot 2020-10-10 210755.png

Calculated column:

Screenshot 2020-10-10 210834.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you may want to try a PQ solution as follows,

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdA9CsMwDAXgqxjPAUtPrkm0BbeB0B8KbaeQ+1+jgpYQsONFaPiekLQsngMHEMixyknRu+fdd/6MeHsJibXzY8zv8LF69WtXBIYtcMki3A5EUUr/QJQpM8jaFhfsOdM2v8aTClen13CvgBt/2I5lQhunAh8vMmjk4pHHZxpH8cYdX78=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Item = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Item", type text}, {"Status", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Time to ACK",
        each
            if [Status] <> "ACT/UNACK" then ""
            else
                [
                    grouped = Table.Group(#"Changed Type", {"Item"}, {{"Time to ACK", each _}}){[Item = [Item]]}[#"Time to ACK"],
                    end = try grouped{[Status="ACT/ACK"]}[Date] otherwise null,
                    dur = end - [Date] ?? ""
                ][dur]
    )
in
    #"Added Custom"

 

 

Screenshot 2020-10-10 175243.png

Measure and calculated column solutions are also available, for fun😁

You may want to refer to the attach file for more details.

Measure:

Screenshot 2020-10-10 210755.png

Calculated column:

Screenshot 2020-10-10 210834.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Kudoed Authors