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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
xsaldana
Regular Visitor

Moving Average every three seconds

Hello! I am attempting to find the moving average for every three seconds in unix time. Any suggestions? Here is an example of values I have to work with. Additionally, I am working with a large dataset with multiple other columns. 

xsaldana_0-1652679385681.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @xsaldana ,

 

Convert the unix time to datetime.

https://whatthefact.bi/power-bi/dax/convert-unix-timestamp-to-date-or-datetime-format-in-power-bi/ 

Column = #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [unix time])

vjaywmsft_0-1652927285845.png

Then create a calculated column with below dax formula:

Column = CALCULATE(AVERAGE('Table'[value]),FILTER('Table','Table'[datetime]>EARLIER('Table'[datetime])-3/86400&&'Table'[datetime]<=EARLIER('Table'[datetime])))

vjaywmsft_1-1652927675567.png

 

Best Regards,

Jay

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @xsaldana ,

 

Convert the unix time to datetime.

https://whatthefact.bi/power-bi/dax/convert-unix-timestamp-to-date-or-datetime-format-in-power-bi/ 

Column = #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [unix time])

vjaywmsft_0-1652927285845.png

Then create a calculated column with below dax formula:

Column = CALCULATE(AVERAGE('Table'[value]),FILTER('Table','Table'[datetime]>EARLIER('Table'[datetime])-3/86400&&'Table'[datetime]<=EARLIER('Table'[datetime])))

vjaywmsft_1-1652927675567.png

 

Best Regards,

Jay

amitchandak
Super User
Super User

@xsaldana , Convert unix time to datetime

power query -https://community.powerbi.com/t5/Desktop/Converting-UNIX-time-to-Date-in-PowerBI-for-Desktop/m-p/130...

https://community.powerbi.com/t5/Desktop/Converting-DateTime-into-Unix-Timestamp-integer-calculated/...

 

 

Then in DAX have column

averageX(Filter(Table, Table[DateTime] <= earlier(Table[DateTime] ) && Table[DateTime] >= earlier(Table[DateTime] ) -time(0,0,3) ) ,[Value] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  
thank you for taking the time to look at this! Unfortunately, this did not work for me. The column processes for a while but doesn't load. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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