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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors