Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Get next milestone in a project

Hi. I'm trying to write a DAX for obtaining the next (imminent) milestone.

 

In my data model I have a table with Milestones. There is Miestone Name and Milestone Date. There is also a table with Projects.

 

I've created a table on the main canvas in BI Desktop, which is a list of projects.

In it, I need a column with DAX that will loop through all the milestones linked to that project, and return a milestone that is the nearest (while ignoring milestones in the past). Can you help?

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a measure.

     

    Measure = var a=LOOKUPVALUE(Project[Projects],[Miestone Name],MAX(Miestone[Miestone Name]))
     var b=SELECTCOLUMNS(FILTER(ALL(Project),[Projects]=a),"test",[Miestone Name])
     return LOOKUPVALUE(Miestone[Miestone Name],[Milestone Date],MINX(FILTER(ALL(Miestone),[Miestone Name] in b),[Milestone Date]))

     

    (3) Then the result is as follows.

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a measure.

     

    Measure = var a=LOOKUPVALUE(Project[Projects],[Miestone Name],MAX(Miestone[Miestone Name]))
     var b=SELECTCOLUMNS(FILTER(ALL(Project),[Projects]=a),"test",[Miestone Name])
     return LOOKUPVALUE(Miestone[Miestone Name],[Milestone Date],MINX(FILTER(ALL(Miestone),[Miestone Name] in b),[Milestone Date]))

     

    (3) Then the result is as follows.

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.