Forum Discussion

bnadir55's avatar
bnadir55
Regular Visitor
8 months ago
Solved

Adding Milestone flags into Line chart in power Bi

Hi,

I have a model view table that comes from SQL server in a direct call ,

in it i have a column by the name "Name" that contains many values , in them I have wording that contains the word "MS" for Milestone and a number e.g. MS3/MS4 etc. (I have also finish_date as the mark date for the MS) , I have built S curve graph from Line chart based on values from this table and many other tables in modelling , now , in this line chart that made of X axis time frame , and Y axis tasks progress , I want to add the Milestones values as flags in the line chart (see example attached in orange diamonds ) ,

I need help with the DAX syntax and how to apply in chart itself to accomplish what I have attached , tried many ways without any success , appreciate your help !

 

  • Anonymous's avatar
    Anonymous
    8 months ago

    Hi bnadir55 ,

    Thank you for reaching out to the Microsoft Fabric Community Forum and for sharing the screenshot. Also thank you burakkaragoz and GrowthNatives  for your helpful response.

     

    The behavior you're seeing is expected and helps identify the root cause. The milestone diamonds are appearing on incorrect or multiple dates because the milestone logic isn't linked to the current X-axis date. Power BI detects that a milestone exists in the data, but not specifically on the plotted date.

    This occurs because the line chart uses a continuous Date axis from the calendar table, while milestone data comes from the Tasks table. If the DAX doesn't check that Finish_Date matches the axis date, Power BI shows the marker across multiple dates.

    To resolve this, the milestone measure should only return a value when the finish date matches the X-axis date, returning BLANK otherwise. This keeps milestones aligned with the S-curve.

    After making these changes, you should see one diamond per milestone, placed on the correct finish date, and aligned with the S-curve. Also, make sure the X-axis uses the Calendar[Date] column, is set to Continuous, and there's an active relationship between Calendar[Date] and Tasks[Finish_Date]. This will ensure milestones display correctly.

     

    Thank you.

7 Replies

  • Hi bnadir55 , you can follow these steps to get the desired result :
    1. Create a Milestone flag column

    DAX
    Is Milestone =
    IF (
        CONTAINSSTRING ( 'Tasks'[Name], "MS" ),
        1,
        0
    )

    Optional :

    DAX 
    Milestone Label =
    IF (
        [Is Milestone] = 1,
        'Tasks'[Name],
        BLANK()
    )


    2. Create a Milestone Y-position measure

    Option A — Fixed height

    DAX 
    Milestone Y =
    IF (
        MAX ( 'Tasks'[Is Milestone] ) = 1,
        0.55,   -- adjust based on your Y scale
        BLANK()
    )

     

    Option B — Snap milestone to S-curve value

    DAX 
    Milestone Y =
    IF (
        MAX ( 'Tasks'[Is Milestone] ) = 1,
        [Cumulative Progress %],
        BLANK()
    )

     

    3.Build the visual 

    Use Line and Scatter chart

    1. Visual → Line and clustered column chart

    2. Remove column values (we’ll only use line + scatter)

    4. Assign fields

    Line values

    • Y-axis (Line):
      Cumulative Progress %

    • X-axis:
      Date

    Scatter values (Milestones)

    • X-axis:
      Finish_Date

    • Y-axis:
      Milestone Y

    • Details:
      Milestone Label

    5. Format the milestone flags

    Scatter formatting

    • Marker shape: Diamond

    • Marker color: Orange

    • Marker size: 10–12

    • Data labels: On

      • Label = Milestone Label

      • Position = Above

    Line formatting

    • Turn markers OFF

    • Keep line smooth

    6. Filter milestones only

    Apply a visual-level filter:

    Is Milestone = 1

     

    Hope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
    💡Found it helpful? Show some love with kudos 👍 as your support keeps our community thriving!
    🚀Let’s keep building smarter, data-driven solutions together!🚀 

  • bnadir55's avatar
    bnadir55
    Regular Visitor

    thx, but already triedd somthing very similler to what sugested, the issue is that the mile stones are not in the right posisions and not aligned with existing line chart ... so ..

  • Hi bnadir55 ,

    The reason your markers are "not in the right positions" is likely because you are trying to combine two different granularities (Continuous Dates for the S-Curve vs. Discrete Dates for Milestones) on a chart type (Combo Chart) that separates them into different axis contexts.

    The most robust way to fix this and guarantee perfect alignment is to stay inside a standard Line Chart and use the "Ghost Line" technique.

    Here is how to do it without changing your visual type:

    1. The DAX (Create the "Ghost" Measure) You need a measure that returns a value only on the dates where a Milestone exists, and BLANK() everywhere else. This ensures it aligns perfectly with your X-Axis Date context.

    Kod snippet'i
     
    Milestone Marker = 
    VAR CurrentMilestone = 
        CALCULATE(
            MAX('Tasks'[Name]), 
            KEEPFILTERS(CONTAINSSTRING('Tasks'[Name], "MS"))
        )
    
    RETURN 
    -- Only return a position if a Milestone exists on this date
    IF(
        NOT(ISBLANK(CurrentMilestone)),
        [Your Cumulative Progress Measure], -- This puts the diamond ON the S-Curve line
        BLANK() 
    )

    Note: If you want the diamonds floating at a fixed height (like 30%), replace [Your Cumulative Progress Measure] with 0.3.

    2. The Visual Setup (The Secret Sauce)

    1. Add this [Milestone Marker] measure to your Y-Axis (alongside your Plan and Actual lines).

    2. Go to Format Pane -> Lines.

    3. Select the Series: Milestone Marker.

    4. Set Stroke Width to 0 px. (This makes the line invisible).

    5. Go to Markers.

    6. Select Series: Milestone Marker.

    7. Turn Markers On.

    8. Choose Shape: Diamond, Size: 10, Color: Orange.

    3. The Labels (Getting the "MS1" Text) To show "MS1", "MS2" next to the diamond:

    1. Turn on Data Labels for the Milestone Marker series.

    2. Expand the Values section inside Data Labels.

    3. Use the "Field" option (Dynamic Labels).

    4. Select your 'Tasks'[Name] column (or a measure that returns the Milestone Name).

    This method forces the Milestones to share the exact same X-Axis (Date) as your S-Curve, solving the misalignment issue instantly.

    Hope this helps you build that perfect dashboard!


    If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
    This response was assisted by AI for translation and formatting purposes.

    • bnadir55's avatar
      bnadir55
      Regular Visitor

      Thx! but did all you wrote in section 1 and 2 , and received unrequested behaviour :

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bnadir55 ,

    Thank you for reaching out to the Microsoft Fabric Community Forum and for sharing the screenshot. Also thank you burakkaragoz and GrowthNatives  for your helpful response.

     

    The behavior you're seeing is expected and helps identify the root cause. The milestone diamonds are appearing on incorrect or multiple dates because the milestone logic isn't linked to the current X-axis date. Power BI detects that a milestone exists in the data, but not specifically on the plotted date.

    This occurs because the line chart uses a continuous Date axis from the calendar table, while milestone data comes from the Tasks table. If the DAX doesn't check that Finish_Date matches the axis date, Power BI shows the marker across multiple dates.

    To resolve this, the milestone measure should only return a value when the finish date matches the X-axis date, returning BLANK otherwise. This keeps milestones aligned with the S-curve.

    After making these changes, you should see one diamond per milestone, placed on the correct finish date, and aligned with the S-curve. Also, make sure the X-axis uses the Calendar[Date] column, is set to Continuous, and there's an active relationship between Calendar[Date] and Tasks[Finish_Date]. This will ensure milestones display correctly.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bnadir55 ,

     

    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.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bnadir55 ,

     

    We haven’t received an update from you in some time. Could you please let us know if the issue has been resolved?
    If you still require support, please let us know, we are happy to assist you.

     

    Thank you.