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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Emilien_Granger
Frequent Visitor

Add a secondary Y axis on a line chart with Legend

Hello Everyone, 

 

I have a line chart showing sales, I use my date(year) field as a legend to display the years and now I need to add a constant line with the quantity available for each product but I can't use the secondary Y axis if I have a legend... The available quantity is the max number of sales that could have been done on a day. tb.png

 

Do you know a workaround for this please ? 

 

Here is dummy and simplified data but my database looks like this : 

DateSalesQuantity AvailableCompany
1/1/202280100Company A
1/1/202175100Company A
1/1/202047100Company A
6/6/202260100Company A
6/6/202132100Company A
6/6/202040100Company A
1/1/2022187230Company B
1/1/2021220230Company B
1/1/2020100230Company B
6/6/2022175230Company B
6/6/2021109230Company B
6/6/2020201230Company B

 

What I have tried : 

- Add a constant Y axis with a function for value 

- Add max line in the analytics pannel : didn't work because I cannot select my 'quantity available' value as a serie

- make two graphs and put the one with quantity available in front => Y axis is not at the same level

 

Thanks a lot for your help

1 ACCEPTED SOLUTION
Emilien_Granger
Frequent Visitor

Hey Amit, Thanks for your answer

 

If this can help, I managed to find a workaround by : 

- duplicating the graph

- removing the year legend from the duplicated graph

- adding two measure as lines (max of my sales and available quantity)

- putting the sales and available quantity as 0 Stroke Width

- adding a max line on my available quantity metric

 

It may not be perfect but it works for me, happy if this can help someone else !   

View solution in original post

4 REPLIES 4
asitm
Helper III
Helper III

@Emilien_Granger 

The native visual doesn't support this, but you can do this with custom visuals available in appsource like the below (these are paid custom visuals though, not free. costs about $4 or so per user)

https://appsource.microsoft.com/en-us/product/power-bi-visuals/yavdaanalyticspvtltd1628223732998.adv...

 

You will need to add colours by clicking on the color icon on top left and manually specifying the years and associated colors.

asitm_1-1677039972447.png

 

 

Emilien_Granger
Frequent Visitor

Hey Amit, Thanks for your answer

 

If this can help, I managed to find a workaround by : 

- duplicating the graph

- removing the year legend from the duplicated graph

- adding two measure as lines (max of my sales and available quantity)

- putting the sales and available quantity as 0 Stroke Width

- adding a max line on my available quantity metric

 

It may not be perfect but it works for me, happy if this can help someone else !   

Hi Emilien,

 

I have followed your method to adjust my line chart. But, I have encountered a problem where the range of both graph are not tally. For my situation, I cannot simply change the range to specific number since it will involve data from lots of date. Do you have any ideas toScreenshot 2023-08-30 092924.png adjust the the range of y-axis ya? 

amitchandak
Super User
Super User

@Emilien_Granger , Not possible as far as I know with line visual(Standard), Only possible with the clustered bar or stacked

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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