cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
friend_anand
New Member

Line graph with markers in Power BI

Hi,

I need to create line graph to show sales growth trends for past 5 years.

1 line per division for 4 divisions.

 

Each division had hired division manager, so we need these lines to differentiate the performance of each division prior to and post joining of division manager.

 

Each division hired manager not at the same time.

Example;

For Division 1, the manager was hired only in year 4

For Division 2, manager was hired in year 2 itself

And so on..

 

So, my requirement is:

For division 1, the line should change colour from year 4.

For division 2 line should change colour from year 2.

And so on..

 

If changing colour of line is not possible, then at least

For Division 1, insert a pointer (or marker) on year 4 intersect

For Division 2, insert a pointer (or marker) on year 2 intersect.

 

Can this be done ?

Please help..

Thanks,

Anand

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @friend_anand ,

 

Try to create a R visual.

 

1. UnPivot.

unpivot.gif

 

2. Create a R visual.

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 

# dataset <- data.frame(Year, DivisionName, ManagerHireYear, Value)
# dataset <- unique(dataset)

# Paste or type your script code here:
library(ggplot2)
library(dplyr)
dataset2<-dataset %>% filter(Year==ManagerHireYear)
ggplot(data = dataset,aes(y = Value, x = Year, colour = DivisionName)) + geom_line(stat="identity") + geom_point(data=dataset2,aes(x=ManagerHireYear,y=Value)) 

r visual.PNG

 

 

Best Regards,

Icey

 

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

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @friend_anand ,

 

Try to create a R visual.

 

1. UnPivot.

unpivot.gif

 

2. Create a R visual.

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 

# dataset <- data.frame(Year, DivisionName, ManagerHireYear, Value)
# dataset <- unique(dataset)

# Paste or type your script code here:
library(ggplot2)
library(dplyr)
dataset2<-dataset %>% filter(Year==ManagerHireYear)
ggplot(data = dataset,aes(y = Value, x = Year, colour = DivisionName)) + geom_line(stat="identity") + geom_point(data=dataset2,aes(x=ManagerHireYear,y=Value)) 

r visual.PNG

 

 

Best Regards,

Icey

 

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

GilbertQ
Super User
Super User

Hi there

Can you please provide some sample data?

And also what the expected result would look like with an image or a mock up via Excel?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Hi,

Thanks for your response.

Here is a sample data:

Division NameManager Hire Year20162017201820192020 YTD
Division A2019843358942693897.3150235.7180282.8
Division B20188757292357129299.8193949.7155159.8
Division C201774420141398155537.8202199.1242639
Division D20189380473804125466.8188200.2207020.2

 

And below is a chart I made in excel with the above table excluding the 2nd column (Manager Hire Date).

 

1.JPG

 

I am looking at an output which will be like below.  I have plotted the year in which the manager was hired for each division.

 

2.JPG

 

Please advise if this is possbile in Power BI visuals.

 

Thanks in advance for your help..

Anand

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors