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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
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] )

@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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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