March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
PowerBI / DAX are well equipped for period groupings that involve days, months, quarters and years. But, despite the description of time intelligence, there does not appear to be much (if any) functionality for time itself. Our dataset is standard IoT log variety:
DATATIMESTAMP,DEVICEID,Vp (other values omitted) in one second intervals. As is so often the case with these things, there is a lot of noise in the readings. Therefore, we need to smooth out the values using averaging.
Given a set of data that looks like this:
DataTimestamp | DeviceName | Vp |
5/22/2016 0:00:00 | NSB-003 | 53.1021 |
5/22/2016 0:00:01 | NSB-003 | 53.0524 |
5/22/2016 0:00:02 | NSB-003 | 53.127 |
5/22/2016 0:00:03 | NSB-003 | 53.1021 |
5/22/2016 0:00:04 | NSB-003 | 53.0773 |
5/22/2016 0:00:05 | NSB-003 | 53.0524 |
5/22/2016 0:00:06 | NSB-003 | 52.9779 |
5/22/2016 0:00:07 | NSB-003 | 53.1021 |
5/22/2016 0:00:08 | NSB-003 | 53.0773 |
How can we calculate the average of now + 4 previous readings, then calculate the delta of change between this "now" average and the average from 3 seconds past? Any help would be greatly appreciated!
Thanks.
Solved! Go to Solution.
In this scenario, because the rows are in one second intervals, we can create an index column so that we can use it to do the average calculation.
Please refer to following steps.
Average_of_Now+4PreReadings = CALCULATE ( CALCULATE ( AVERAGE ( Table1[Vp] ), Table1[Index] >= VALUES ( Table1[Index] ) - 4, Table1[Index] <= VALUES ( Table1[Index] ) ), ALLEXCEPT ( Table1, Table1[DeviceName], Table1[Index] ) )
Average_from_3SecPast = CALCULATE ( CALCULATE ( AVERAGE ( Table1[Vp] ), Table1[Index] >= VALUES ( Table1[Index] ) - 3, Table1[Index] <= VALUES ( Table1[Index] ) ), ALLEXCEPT ( Table1, Table1[DeviceName], Table1[Index] ) )
Delta_Change = Table1[Average_of_Now+4PreReadings] - Table1[Average_from_3SecPast]
Regards,
I think you just made my week, Mr. Hou. Testing now, but I do believe you've nailed it. I can't thank you enough, sir.
In this scenario, because the rows are in one second intervals, we can create an index column so that we can use it to do the average calculation.
Please refer to following steps.
Average_of_Now+4PreReadings = CALCULATE ( CALCULATE ( AVERAGE ( Table1[Vp] ), Table1[Index] >= VALUES ( Table1[Index] ) - 4, Table1[Index] <= VALUES ( Table1[Index] ) ), ALLEXCEPT ( Table1, Table1[DeviceName], Table1[Index] ) )
Average_from_3SecPast = CALCULATE ( CALCULATE ( AVERAGE ( Table1[Vp] ), Table1[Index] >= VALUES ( Table1[Index] ) - 3, Table1[Index] <= VALUES ( Table1[Index] ) ), ALLEXCEPT ( Table1, Table1[DeviceName], Table1[Index] ) )
Delta_Change = Table1[Average_of_Now+4PreReadings] - Table1[Average_from_3SecPast]
Regards,
I think you just made my week, Mr. Hou. Testing now, but I do believe you've nailed it. I can't thank you enough, sir.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |