Forum Discussion
Find Latest Value from Array
- 6 years ago
Hmm, I am guessing that the last row of data doesn't have a reading. Can you try changing the mesure to this?
Last Battery = VAR _MaxTime = CALCULATE ( MAX ( 'SensoEvents'[TimeStamp] ), KEEPFILTERS ( ALL ( 'SensoEvents'[TimeStamp] ) ) ) RETURN CALCULATE ( SUM ( 'SensoEvent'[Battery] ), 'SensoEvents'[TimeStamp] = _MaxTime )See if keeping the other filters lets us get a result.
When you say last, how do you determine that? Is there a date/time field on the table?
Hi,
I do have a timestamp attached to the data, I have an example of the table below.
| Timestamp | battery |
| 06/10/2019 20:42:06 | 0 |
| 06/10/2019 20:42:06 | 0 |
| 06/10/2019 20:42:06 | 0 |
| 06/10/2019 20:42:06 | 3.3 |
| 06/10/2019 20:42:06 | 3.3 |
| 06/10/2019 20:42:06 | 3.2 |
| 06/10/2019 20:42:06 | 3.1 |
Ultimately, I need to return the last value (3.1).
Andrei
- jdbuchanan716 years agoSuper User
All of those times are the same (20:42:06) but assuming they are not that way in your data it will be something like so:
Last Battery = VAR _MaxTime = CALCULATE( MAX ( 'Table'[Timestamp] ), ALL ( 'Table'[Timestamp] ) ) RETURN CALCULATE( SUM ( 'Table'[battery] ), 'Table'[Timestamp] = _MaxTime )- AndreiFlorian6 years agoFrequent Visitor
Hi, I tried the code provided but I get the following errors when hovering over the table names:
Parameter is not the correct type
Cannot find name '[Timestamp]'
Andrei.
- jdbuchanan716 years agoSuper User
Is the field called something else in your model or is it not a date/time field?