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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Time delta for a calculated column, when sorted by time

I have a set of data, each with a timestamp. 

 

I am trying to create a calculated column that, for each row, contains the time delta between that row and it's chronological predecessor, when the data is sorted by time ascending

 

Cenceptually this seems easy - but trying to specify the sort order in the calculated column is proving difficult....any ideas? 

 

 

 

6 REPLIES 6
Anonymous
Not applicable

I wondered if this was a limitation powerBI imposes on live streamed data over historic data, the former of which is only available in the latter after 24 hours. 

 

However, trying that it seems to make no difference to the output. Frustratingly poiwerBI seems to have sacrificed functionbality for accesibility. It is a lot prettier than messing around with the database and scripts directly, but has far more limitations on what ca neasily be achievd - or at least that seems to be the case so far!

 

Hi @Anonymous ,

Try the following formula:

Measure = 
IF(
    MAX(events[times tamp]) = MINX(ALL(events),events[times tamp]),
    BLANK(),
    FORMAT( 
        MAX(events[times tamp]) - MAXX(
            FILTER(
                ALL(events),
                events[times tamp] < MAX(events[times tamp])
            ),
            events[times tamp]
        ), 
        "0.00000" 
    )
)

v-kkf-msft_0-1617002202604.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Hi @Anonymous ,

 

Did I answer your question? If you can get the correct result, please accept as solution so that users with the same problem can find it quickly.

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

amitchandak
Super User
Super User

@Anonymous , Create a new column like

[timestamp] - maxx(filter(Table, [timestamp] < earlier([timestamp])),[timestamp])

Anonymous
Not applicable

Thanks - almlost: 

dbrb2_0-1616694054486.png

 

My time collumn is called "timestamp" - and contains time data - but I'm getting the error shown in the image above...

Anonymous
Not applicable

Ok...it looks like I can't create that in a "measure" - it has to be in a new column. But since I am consuming a remote data source, I can't create a new column. I think this means that this is just a limitation of powerBI - unless I am missing something...

 

It seems that powerBI is potentially a good agregator of myriad data sources, but analysis of those feeds theselves it is a better done at source?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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