Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mrooney87
Regular Visitor

Data labels on a line in line and stacked column chart use the wrong measure when a legend is added

Hi,

 

I have a report which includes a combined line stacked column chart, and have been asked to add data labels for the min and max values on the line.

 

I normally achieve this by creating another measure and using it for the data labels. This works fine for other chart types and for this chart when there is no legend used for the columns, but as soon as I add a legend to the columns, the data labels on the line revert back to showing the measure that is being charted - I've confirmed this by using a measure that's just a hardcoded constant value for the labels, so it doesn't appear to be to do with filter context.

 

I've recreated this in one of the PBI sample files - please see the screenshots below.

The file I used is here and my DAX is below.

 

DAX for measures used in the screenshots:

Average order quantity =
AVERAGE Sales[Order Quantity] )
 
Total Sales Amount =
SUM ( Sales[Sales Amount] )
 
Constant Value = 1
 
Max avg order quantitiy label =
VAR max_value =
    CALCULATE (
        MAXX (
            SUMMARIZECOLUMNS ( 'Date'[Month], "avg", [Average order quantity] ),
            [avg]
        ),
        ALL ( 'Date' )
    )
RETURN
    IF ( [Average order quantity] = max_value, [Average order quantity], BLANK () )

 

Screenshot 1: [Max avg order quantitiy label] measure used for line data labels. Charts are the same just with a legend added in the bottom one.

mrooney87_0-1731632261027.png

 

Screenshot 2: Constant Value measure

mrooney87_1-1731632644945.png

Can anyone explain why this is happening? Is it a bug? A deliberate feature? Or something I've done wrong?
 
Thanks!
3 REPLIES 3
Anonymous
Not applicable

Hi @mrooney87 ,

 

When you use column legend, the categories in column legend are used as one of the criteria for filtercontext of the visual. Please show the max average quantity measure as a line as well, but it will only show one value.

vmengmlimsft_0-1731898633703.png

vmengmlimsft_1-1731898655387.png

 

 

Best regards,

Mengmeng Li

 

Thanks for your reply! Are you able to explain a bit more how the filter context has this impact, especially for the measure which is just = 1? It changes from showing all 1 to showing the values from Average order quantity, which does not make sense to me.

 

When I run the DAX query from performance analyser, I can see that Constant_Value is present in the table

__DS0BodyLimited and is evaluating to 1 for every row, as I would expect, but the labels are showing a different series.

 

In the meantime, I am using a similar workaround to what you suggested, and I have make the line colour white and removed the measure name because I don't want the labels measure to show up in the legend. But if there is a DAX solution, I would rather do that.

Anonymous
Not applicable

Hi @mrooney87 ,

 

This becuase Constant Value does not have any filter context, it just 1. Only measure can't clear the filter on the legend of the visual. In fact, when you use Legend, you can see that Text Lable does not even recognize the max average measure.

 

 

Best regards,

Mengmeng Li

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.