Forum Discussion

friend_anand's avatar
friend_anand
New Member
6 years ago
Solved

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

  • Hi friend_anand ,

     

    Try to create a R visual.

     

    1. UnPivot.

     

    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)) 

     

     

    Best Regards,

    Icey

     

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

3 Replies

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi friend_anand ,

     

    Try to create a R visual.

     

    1. UnPivot.

     

    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)) 

     

     

    Best Regards,

    Icey

     

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

  • 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?
    • friend_anand's avatar
      friend_anand
      New Member

      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).

       

       

      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.

       

       

      Please advise if this is possbile in Power BI visuals.

       

      Thanks in advance for your help..

      Anand