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

Take the last 5 minutes from the max time

Hi,

I have a table of calls updated from production for every ETL DB refresh.

I need to show stats about calls based on the following :

Showing stats for the last 5 minutes until the max time of call inserted : to be more clear i should find the last call inserted and from it's call time I should calculste number of calls from 5 minutes to this call.

Any help?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

measure  =

var _max = maxx(allselected(Table), Table[Last Call Datetime])

return

calculate(Count(Table[Call ID]), filter(Table, Table[Last Call Datetime] > _max -time(0,5,0) && Table[Last Call Datetime]  <= _max) )

View solution in original post

2 REPLIES 2
isabella
Employee
Employee

Hi @Anonymous 

 

You want to import the last 5 minites data into power bi desktop,right? If your database is from SQL Server ,you can use below query statement to import the data.

 

My test table is as this :

 

isabella_0-1654153554257.png

 

 

Use the query statement to get the last 5 minites data:

 

  DECLARE @MAXDATE DATETIME2 = (SELECT MAX(DATEINSERTED) FROM tablecall)

  DECLARE @LEFTDATE DATETIME2 = (select DATEADD(mi,-5,@MAXDATE))

 

  SELECT * FROM tablecall  where DATEINSERTED > @LEFTDATE ORDER BY DATEINSERTED

 

 

isabella_1-1654153554260.png

 

 

 

The imported data  is as this:

isabella_2-1654153554261.png

 

 

Best Regards,

Community Support Team _Isabella

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 , Try a measure like

 

measure  =

var _max = maxx(allselected(Table), Table[Last Call Datetime])

return

calculate(Count(Table[Call ID]), filter(Table, Table[Last Call Datetime] > _max -time(0,5,0) && Table[Last Call Datetime]  <= _max) )

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.