Forum Discussion
heuristik
10 years agoRegular Visitor
Moving Average in Seconds
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) funct...
- 10 years ago
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.
- Add an index column in Query Editor.
- Create three columns for average of now + 4 previous readings, average from 3 seconds past and delta change.
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,
- 10 years ago
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.
v-sihou-msft
10 years agoMicrosoft Employee
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.
- Add an index column in Query Editor.
- Create three columns for average of now + 4 previous readings, average from 3 seconds past and delta change.
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,
- heuristik10 years agoRegular Visitor
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.