Forum Discussion
Line chart data label on min, max, current points only for dynamic hierarchy (sample solution)
- 7 months ago
v-prasare Thank You
i have been playing around with chatgpt to help me , the below works on gettinfg the last month total only but not when i roll up to qtr where i want the ucrrent or last qter total to displayThis works for last only that has start of month date
LastDateValueLabel =
VAR MaxFactDate =
CALCULATE(
MAX(FACT[Date]),
ALLSELECTED('Calc_Calendar')
)
RETURN
IF(
MAX('Calc_Calendar'[Date]) = MaxFactDate,
FACT[ActualBaseMeasAgg],
BLANK()
)
Now trying date hierarchy:VAR CurrentMaxDate =
CALCULATE(
MAX(FACT[Date]),
ALLSELECTED('Calc_Calendar')
)VAR CurrentPeriod =
SWITCH(
TRUE(),
ISINSCOPE('Calc_Calendar'[DateStartOfMonthDescr]), "Month",
ISINSCOPE('Calc_Calendar'[DateFinQuarterDescr]), "Quarter",
ISINSCOPE('Calc_Calendar'[DateFinYearDescr]), "Year",
"Other"
)RETURN
SWITCH(
CurrentPeriod,
"Month",
CALCULATE(
FACT[ActualBaseMeasAgg],
FILTER(
ALL('Calc_Calendar'),
'Calc_Calendar'[Date] = CurrentMaxDate
)
),
"Quarter",
CALCULATE(
FACT[ActualBaseMeasAgg],
DATESQTD('Calc_Calendar'[Date])
),
"Year",
CALCULATE(
FACT[ActualBaseMeasAgg],
DATESYTD('Calc_Calendar'[Date])
),
BLANK()
)
Hi icassiem,
Set the x-axis to your Date hierarchy (Year → Quarter → Month → Day). Add Base Measure as the main Y value series. Add either:
- Current Period Label, Min Label, Max Label as additional series; or
- Composite Label (Current/Min/Max) as a single series.
Turn Data labels ON for these label series (Power BI shows a label only where the measure returns a non‑blank value). Optionally add Label Type (Tooltip) to the visual tooltips.
If above solution does not works as lbendlin suggested please share sample pbix file so that we will reproduce from our end.
Thanks,
Prashanth Are
- icassiem7 months agoPost Prodigy
v-prasare , lbendlin thank you
thr problem is more, im not able to do the dax calc to show in the cols
tried following this example: How to label the latest data point in a Power BI line or area chart — DATA GOBLINS
was hoping someone could share me a pbix sample of the calcs col etc
- v-prasare7 months agoCommunity Support
Hi icassiem,
To achieve this, we use DAX measures that return values only for the current, minimum, or maximum period within the active date hierarchy context. Power BI automatically displays data labels only for those points where the measure returns a value, while all other points remain unlabeled.Total Sales := SUM ( 'Fact Sales'[SalesAmount] ) Last Visible Date := MAX ( 'Dim Date'[Date] ) Min Sales := MINX ( VALUES ( 'Dim Date'[Date] ), [Total Sales] ) Max Sales := MAXX ( VALUES ( 'Dim Date'[Date] ), [Total Sales] ) Composite Label := VAR _CurrentValue = [Total Sales] VAR _MinValue = [Min Sales] VAR _MaxValue = [Max Sales] VAR _LastDate = [Last Visible Date] VAR _IsCurrent = MAX ( 'Dim Date'[Date] ) = _LastDate VAR _IsMin = _CurrentValue = _MinValue VAR _IsMax = _CurrentValue = _MaxValue RETURN SWITCH ( TRUE (), _IsCurrent, _CurrentValue, _IsMax, _CurrentValue, _IsMin, _CurrentValue, BLANK () )please try above measure, which should help you resolve the issue. If not please share sample pbix file or sample data in usable format. so, that can try to repro this scenario from our end
Thanks,
Prashanth