Forum Discussion
Line chart data label on min, max, current points only for dynamic hierarchy (sample solution)
Hi,
i posted previously to show data lables on specific points but dynamic for qtr, year, month visual selection
here is my prev post, and i received help by trying to create the additional measures
"""
https://data-goblins.com/power-bi/label-latest-datapoint#:~:text=MORE%20ELEGANT%20VISUALS%3A
Measure-Label := IF ( MAX ( 'DIM_Date'[Date] ) < CALCULATE ( MAX ( 'FACT'[Date] ), ALL ( 'FACT' ) ), BLANK (), [Measure])
// Calculates the latest date in the 'FACT' table
Latest Data Point := CALCULATE ( MAX ( 'FACT'[Date] ), ALL ( 'FACT' ))
//Create the calculated column in our Date table, Evaluates 'TRUE' if the date is the latest date or the end of the month.
IsLatestorEOM := 'DIM_Date'[Date] = [Latest Data Point] || 'DIM_Date'[Date] = EOMONTH ( [Date], 0 )
//we revise our measure label to a simple CALCULATE statement with a column filter on this new calculated column that we created. Filters the measure to only show the value on the latest date or at the end of the month .
Measure Label := CALCULATE ( [Measure], 'DIM_Date'[IsLatestorEOM] = TRUE)
"""
i am battling badly to get even one measure going (current period, min, max) and i cant get it dynamic enough for year, qtr, month grain view, can someone please share a sample solutions from a line chart with the date hierarchy and addtional data lable points i can follow to replicate?
thank you
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()
)
12 Replies
- lbendlinSuper User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- icassiemPost Prodigy
lbendlin thank you
i cant share any of the data, even though i try to to mask the data
basically, i tried creating a calaculated col for when data selected = curr mont show curr mon total sales
Example of month view
Startofmonth - Sales
01/01/25 - 1,000,000
01/02/25 - 2,000,000
01/03/25 - 3,000,000
01/04/25 - 1,000,000
01/05/25 - 5,000,000 (current) show data label for current month of 5m
but when in quarter view the same calc measure or col must show data label of 6,000,000 which is the total of current qtr, using a normal date hierarchy (year, qtr, month, date (som))
Please help?
- v-prasareCommunity Support
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
- icassiemPost 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-prasareCommunity 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
- v-prasareCommunity Support
we are looking into it
- icassiemPost Prodigy
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()
)