Forum Discussion
Show only last value in line chart?
Dears
I've created a line chart in Power BI. How can I display the value of the last data point? I only want to see the value of the last data point, all other data point labels should not be shown.
Currently i can only show either all labels or no label
Here is a mockup:
tnx for any assistance 🙂
Hi!
I don't know how your data is structured so you have to adjust accordingly, but basically you want to figure out the max date where there is a value and then return blank() for all values that aren't the last point.
LastValueLabel = VAR __LastDate = CALCULATE(MAX('Dates'[Date]), ALL('Dates')) RETURN IF( SELECTEDVALUE('Dates'[Date]) = __LastDate, [YourMainMeasure], BLANK() )And then add that measure as the Value on the Data Label for your series.
Good luck!
3 Replies
- TomasAndersson
Solution Sage
Hi!
I don't know how your data is structured so you have to adjust accordingly, but basically you want to figure out the max date where there is a value and then return blank() for all values that aren't the last point.
LastValueLabel = VAR __LastDate = CALCULATE(MAX('Dates'[Date]), ALL('Dates')) RETURN IF( SELECTEDVALUE('Dates'[Date]) = __LastDate, [YourMainMeasure], BLANK() )And then add that measure as the Value on the Data Label for your series.
Good luck!
- SamWiseOwl
Super User
Hi Hugo999
There are two ways you could try a measure or a Top Filter.
Create a measure that tests if the current data point is equal to the highest in that column.
Right click on your table and choose create new measure
Last point =
If(SelectedValue(table[YY-MM column]) = Calculate(Max(table[YY-MM]), AllSelected(table[YY-MM]))
, [Your calculation],Blank()
)To apply a filter go the Filter pane and under Filters on this visual, go to your [yy_mm] column.
Change it from basic filters to Top N.
Choose 1 and then use the [yy-mm] field in the calculation part of the filter.
Change this to MAX.
This method might remove more than your want!
- Hugo999Frequent Visitor
thank you all for your replies.
i addition to the base problem, i had a mixture of datatypes and empty fields. so i had to correct that and query for the last not empty value, ending up with this:
ucPerabc_lastval =
VAR LastIndex =
MAXX(
FILTER(ALL(ucanen[Zeit.Monat]); NOT(ISBLANK([ucPerabc])));
ucanen[Zeit.Monat]
)
-- Get the last index where ucPerabc is not blank
VAR CurrentIndex = SELECTEDVALUE(ucanen[Zeit.Monat]) -- Get the current row’s index value
VAR LastucValue = CALCULATE([ucPerabc]; ucanen[Zeit.Monat] = LastIndex) -- Calculate the uc value for the last valid index
RETURN
IF(
CurrentIndex = LastIndex; -- Compare the current row's index with LastIndex
ROUND(LastucValue; 0); -- Show the value only for the last index where data is present
BLANK()
)i added that measure as y Axis and showed the value.