Forum Discussion
Return a value based on a condition
- Anonymous4 years ago
Hi Victormar ,
From my understanding, you want to create a IsLatest column.
You could create a measure like
IsLatest = VAR _MAX = MAXX ( FILTER ( ALL ( 'Table' ), [VALUE] <> BLANK () && [ID] = MAX ( 'Table'[ID] ) ), [DATE] ) RETURN IF ( _MAX = MAX ( 'Table'[DATE] ), 1, IF ( SUM ( 'Table'[VALUE] ) <> BLANK (), 0 ) )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
What are you doing to create this custom table that you have shown?
You can simple pick the latest values in this table and then plot the line chart based on that.
If you don't need the IsLatest flag explicitly, you can drop it and only have a table with latest values.
If you can provide more information about the data, I cna show how this can be done
- Victormar4 years ago
Helper V
Hi,
Thanks for answering. The table is in a sql server, I am just importing it to power bi. The thing is that it is updated every day, so the value 1 for IsLatest column is changing everyday, only if there is a reading from the value.
The table I have put was just a simplified copy to show what I have
I mean that while we have a timestamp column, somethimes the table would have a new row without data for the same ID, so IsLatest would still be in an earlier date.
I need the IsLatest to show in a table the last reading we have, but then I cannot use the table to filter the line chart, because there I want to have all readings.
ID DATE ISLATEST VALUE 1 1-1-21 1 2-1-21 0 1000 1 4-1-21 1 1500 1 8-1-21 2 2-1-21 0 100
2 4-1-21 0 200 2 8-1-21 1 450 3 2-1-21 So we would have '1' for the latest reading, but when there is a new reading, the column 'IsLatest' would change from 0 to 1, while adding another value to the Mileage column. We can also have a new row with IsLatest 'blank', which will result in no value for the measurement column.
Hope it makes sense.