Forum Discussion

mdm2025's avatar
mdm2025
Helper I
1 year ago
Solved

Custom Reference Line Using DAX

Hello everyone, 

 

I wanted to check if anyone has found a workaround for setting up a custom calculated reference line in Power BI.

While the default reference line options are useful and make sense in many scenarios, I would like to use a custom DAX measure instead. Unfortunately, Power BI currently doesn’t seem to support this directly.

To clarify what I’m aiming for:
I’d like to display a custom calculated line for each column in a column chart. If that’s not possible for multiple columns, is there at least a way to achieve this for a visual with a single column?

 

I’ve included an example below to illustrate the goal more clearly.


Currently I am using a column insted of the line but doesn't look that great. 


Thanks in advance for any ideas or suggestions!

Best,

Marius

  • Hi mdm2025,

    since the combo chart isn’t fitting your visual needs, and you are trying to show a separate custom line for each column using a measure, your current workaround with an extra column makes sense for now.
    At the moment, Power BI doesn’t have a built-in way to draw individual lines on each bar using a measure. That’s why people usually go for the combo chart method, even though it has its own limitations.

    Hope this helps if you have any queries we are  happy to assist you further.
    Best Regards,
    Harshitha.

10 Replies

  • v-hjannapu's avatar
    v-hjannapu
    Community Support

    Hi mdm2025,

    I would also take a moment to thank jaineshp wardy912  for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

    Best Regards,
    Harshitha.

    • v-hjannapu's avatar
      v-hjannapu
      Community Support

      Hi mdm2025,
      I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.

      Regards,
      Harshitha.

  • Hi mdm2025 

     

     You will need to create a measure similar to the below, I am setting different targets for different days of the week.

     

    Custom Reference Line = 
    SWITCH(
        SELECTEDVALUE('Date'[Day Name]),
        "Monday", 1500,
        "Tuesday", 1300,
        "Wednesday", 500,
        "Thursday", 1200,
        "Friday", 900,
        "Saturday", 800,
        "Sunday", 700,
        BLANK()
    )

     

    Add that as the line y-axis in a line and clustered column chart for the following result

     

    You could also add it as a tooltip for better visibility

     

     

    I hope this helps! Please give a thumbs up and mark as solved if it does, thanks!

  • jaineshp's avatar
    jaineshp
    Memorable Member

    Hi ,

    To create per-category reference lines, use a Line and clustered column chart plus a custom DAX measure. First, define a measure that returns the desired “target” for each category (e.g. day of week) using SWITCH and SELECTEDVALUE. For example, if your axis is the day of the week, you could write:

    Custom Reference Line =
    SWITCH(
    SELECTEDVALUE('Date'[Day Name]),
    "Monday", 1500,
    "Tuesday", 1300,
    "Wednesday", 500,
    "Thursday", 1200,
    "Friday", 900,
    "Saturday", 800,
    "Sunday", 700,
    BLANK()
    )

    mdm2025

  • Hi mdm2025 can you please share pbix file so that I can understand what's going on

     

     

  • Hello everyone, 

    Thank you for your prompt reply on this. 

    I am not looking for the combo chart option as doesn't meet the visual requirements. The goal is to apply a individual line calculated on a custom measure for each of the columns. That is why I am using another column at the moment in lack of something similar. 
    I will share a pbi example file once I put one together which will hopefully clarify the intent. 

     

    Thank you,

    Marius

    • v-hjannapu's avatar
      v-hjannapu
      Community Support

      Hi mdm2025,

      since the combo chart isn’t fitting your visual needs, and you are trying to show a separate custom line for each column using a measure, your current workaround with an extra column makes sense for now.
      At the moment, Power BI doesn’t have a built-in way to draw individual lines on each bar using a measure. That’s why people usually go for the combo chart method, even though it has its own limitations.

      Hope this helps if you have any queries we are  happy to assist you further.
      Best Regards,
      Harshitha.

      • v-hjannapu's avatar
        v-hjannapu
        Community Support

        Hi mdm2025,
        I wanted to follow up and see if you have had a chance to review the information that was shared. If you have any additional questions or need further clarification, please don’t hesitate to reach out. I am here to assist with any concerns you might have.

        Regards,
        Harshitha.