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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
HamidBee
Power Participant
Power Participant

How can I plot my DAX measure as a legend as well as values?

I am working with the following DAX:

 

Petrol or Diesel = 
VAR A =
    ADDCOLUMNS (
        'Table',
        "Petrol or Diesel",
            IF (
                'Table'[Amount]=1,
                "Petrol",
                "Diesel"
            ))
    
RETURN
    MAXX ( A, [Petrol or Diesel] )

 

 

I am trying to plot a clustered column chart using the above DAX measure. When I drag it into values it plots but I can't drag it into legends inorder to create the seperate groups. I understand that it is a numerical value. Does anyone know a way to solve this issue?.

 

I would like to see two bars. One for Petrol and one for Diesel. Please find attached the file below:

 

https://www.mediafire.com/file/kstnvgk7afmvsk4/Example_File.pbix/file

 

Thanks.

1 ACCEPTED SOLUTION

Hi, @HamidBee 

As you said, measure cannot be dragged into 'Axis' or 'Legend'.

You need to add a calculated column or add another calculated table as below:

Calculated column:

Petrol or Diese =
IF ( 'Table'[Amount] = 1, "Petrol", "Diesel" )

Calculated table:

Table 2 = ADDCOLUMNS (
        'Table',
        "Petrol or Diesel",
            IF (
                'Table'[Amount]=1,
                "Petrol",
                "Diesel"
            ))

This will allow you to drag the field 'Petrol or Diesel' into matrix to create the seperate groups.

14.png

Best Regards,
Community Support Team _ Eason

View solution in original post

5 REPLIES 5
v-easonf-msft
Community Support
Community Support

Hi, @HamidBee 

What is your expected result roughly?
Do you want the legend to show the value of "A OR B" or the count of "A OR B" ?
Please share a sample file for further research.

 

Best Regards,
Community Support Team _ Eason

Thank you for your reply. I have attached the file in the main question area above. I have also tried to provide more detail in terms of what it is that I am looking for.

 

Thanks

Hi, @HamidBee 

As you said, measure cannot be dragged into 'Axis' or 'Legend'.

You need to add a calculated column or add another calculated table as below:

Calculated column:

Petrol or Diese =
IF ( 'Table'[Amount] = 1, "Petrol", "Diesel" )

Calculated table:

Table 2 = ADDCOLUMNS (
        'Table',
        "Petrol or Diesel",
            IF (
                'Table'[Amount]=1,
                "Petrol",
                "Diesel"
            ))

This will allow you to drag the field 'Petrol or Diesel' into matrix to create the seperate groups.

14.png

Best Regards,
Community Support Team _ Eason

as i have a dynamic parameter for user to select on runtime. both calculated table and column not working . Any other method?

 

amitchandak
Super User
Super User

@HamidBee , You can not drag the measure in legend

 

seem like you need dynamic segmentation

 

https://www.daxpatterns.com/dynamic-segmentation/

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors