Forum Discussion
HELP
Hi,
I need to create an Output column as below.
I have one column that reads [energy] data per socket across multiple sockets per by seconds. the energy reading per [socket_id] will increase unless the socket is switched off which then energy will be ZERO. when the socket is switched back on the energy readings will start increasing again from ZERO upwards. What I need to do is, when the socket is switched off and back on apply the last MAX energy reading before Switch off (per socket) and apply the reading to all new readings. Before the Socket is switched off the Energy column and Output column should be the same (as below). I only have one table with all columns
read_at socket_id Energy Output
18/10/2019 13:01:01 1 0.10 0.10
18/10/2019 13:01:05 1 0.30 0.30
18/10/2019 13:01:07 1 0.50 0.50
18/10/2019 13:01:09 1 0.60 0.60
18/10/2019 13:01:11 1 1.00 1.00
18/10/2019 13:01:15 1 0.00 1.00
18/10/2019 13:01:18 1 0.30 1.30
18/10/2019 13:01:20 1 0.50 1.50
18/10/2019 13:01:22 1 0.70 1.70
18/10/2019 13:01:25 1 0.00 1.00
18/10/2019 13:01:26 1 0.20 1.20
I have been given the following code
Output =
VAR maxenerge =
CALCULATE ( MAX ( 'readings'[Energy] ), ALLEXCEPT ( 'readings', 'readings'[socket_id] ) )
RETURN
IF (
'readings'[read_at]
<= CALCULATE (
LOOKUPVALUE ( 'readings'[read_at], 'readings'[Energy], maxenerge ),
ALLEXCEPT ( 'readings', 'readings'[socket_id )
),
'readings'[Energy],
maxenerge + 'readings'[Energy]
)
Can someone urgently help please?
however, get the following error.
"A table of multiple values was supplied where a single value was expected"
12 Replies
- Ashish_MathurSuper User
Hi,
Shouldn't the result in the last 2 rows of the output column be 1.7 and 1.9?
- PSRaiHelper III
Ashish_Mathur That's correct, the table shows the correct reading
- Ashish_MathurSuper User
So am I correct or am I wrong?