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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
adarshthouti141
Frequent Visitor

Milestone Trend analysis in Power BI using python

I have found a PowerBI file with trend analysis. Here the user invoked separate rows with 'BI', '45 Line', and the dates to plot the data points. 

adarshthouti141_0-1725890830598.png

But I have a data which is of different kind where the 'Sample Date' is in different column which is 'Data Date' and I have activity 'Finish Date' . 

Can anyone please tell me how I can plot the 'Data Date' in x-axis and 
the 'Finish Date' with respect to the 'Activity ID' in y-axis? 


adarshthouti141_1-1725890846726.png

I have tried to modify the python code and implement with respect to my requirement, but that isn't working. 

adarshthouti141_2-1725890890254.png

 

This is the code from the sample file and below is the modified code by me. 

adarshthouti141_3-1725890975773.png

 

 

5 REPLIES 5
lbendlin
Super User
Super User

But I have a data which is of different kind where the 'Sample Date' is in different column which is 'Data Date' and I have activity 'Finish Date' . 

Please elaborate.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Ok, Let me give you an example of how my data is created in the power bi dataset. I have two tables named "PROJECT" and "TASK" where 
1) the Project completion dates are present in "PROJECT" table and
2) the activity completion dates are present in "TASK" table

The "PROJECT" table is created like below : 

Project_ID         Project_Completion_Date
-----------------------------------------------
proj_1                        14-Jan-2024    
proj_2                        22-Mar-2024  
proj_3                        18-May-2024 

So I want a 45 degree line which need to be created in the X-Axis with the above Project Completion Dates with Datapoints

Next coming to the "TASK" table the data is created like below : 

Project_ID             Activity_ID                Activity_Completion_Date            
----------------------------------------------------------------------------
proj_1                     A1000                              05-Jan-2024              
proj_1                     B1200                              08-Feb-2024
proj_2                     A1000                              09-Jan-2024 
proj_2                     B1200                              25-Feb-2024   
proj_2                     D1520                              12-Mar-2024
proj_3                     A1000                              19-Jan-2024
proj_3                     B1200                               31-Jun-2024 
proj_3                     D1520                               17-Apr-2024


So I want to plot the above dates in the y-axis as the Activity Completion Dates by differentiating with the help of "Activity ID" in the Milestone trend analysis chart using Python. 

Note: Here the "Project" table and the "Task" table are connected using "Project ID" with one to many relationships. How can I achieve it?

I want the output like below

adarshthouti141_0-1725894524648.png

 

 

 

proj_3                     B1200                               31-Jun-2024 

 

 

No such date exists.

 

You can do this in a built-in scatter plot when you convert the dates to their integer values.

 

lbendlin_1-1725895250621.png

If you want temporal values on both axes you would need to use custom visuals (including Python or Deneb)

 

lbendlin_2-1725895665954.png

 

Adding a regression line in Vega-Lite scatterplot @ Fabio Franchino

 

lbendlin_0-1725895919475.png

 

How to achieve this in power bi? 

Can you check the code which is used above that uses the libraries such as pandas, numpy and matplotlib

lbendlin_0-1725901962409.png

Your code seems overly complex.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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