cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kane2
Helper I
Helper I

2 Lines in a Line chart

Hello guys, I need aid in an issue regarding my line chart as seen below. I currently have a filter on the line chart so as to seperate the data displayed by years. The data the chart is pulling from comes from my sharepoint list as seen below. Any help would be appreciated!

 

Kane2_0-1670301958739.pngKane2_1-1670301982803.png

@WarrenBelz @RandyHayes @Drrickryp 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Kane2 ,

 

I made a sample for you:

 

Create a list with two years of data.

vxiaochenmsft_0-1670313120685.png

 

 

Add a line chart, set Items to the following function and select Series.

AddColumns(Filter(List26,Year="2021") As Temp ,"Y2022",LookUp(Filter(List26,Year="2022"),Temp.Season=Season).Number)

In your database it should be:

AddColumns(Filter(‘A350 Withdrawal Count’,Year="2022") As Temp ,"Y2023",LookUp(Filter(‘A350 Withdrawal Count’ ,Year="2023"),Temp.Month=Month).Withdrawal Count’)

vxiaochenmsft_1-1670313120689.png

 

 

Set the number of Series to display.

vxiaochenmsft_2-1670313120690.png

 

Best Regards,

Wearsky

View solution in original post

v-xiaochen-msft
Community Support
Community Support

Hi @Kane2 ,

 

I made a sample for you:

 

Add a dropdown in app.

vxiaochenmsft_0-1670376359248.png

 

 

Set 'items' to the following function.

If(Dropdown1.Selected.Value="All",AddColumns(Filter('A350 Withdrawal Count',Year="2022") As Temp,"Y2023",LookUp(Filter('A350 Withdrawal Count',Year="2023"),Temp.Month=Month).'Withdrawal Count'),AddColumns(Filter('A350 Withdrawal Count',Year=Dropdown1.Selected.Value) As Temp,"Y2023",LookUp(Filter('A350 Withdrawal Count',Year="2022"),Temp.Month=Month).'Withdrawal Count'))

vxiaochenmsft_1-1670376359254.png

 

 

Set the number of Series to display.

If(Dropdown1.Selected.Value=”All”,2,1)

vxiaochenmsft_2-1670376359255.png

 

Best Regards,

Wearsky

View solution in original post

7 REPLIES 7
Kane2
Helper I
Helper I

P.S. sorry i forgot to aid this in the original post. I am looking to develop a feature which can display both the lines of 2022 and 2023 in one chart.

v-xiaochen-msft
Community Support
Community Support

Hi @Kane2 ,

 

I made a sample for you:

 

Create a list with two years of data.

vxiaochenmsft_0-1670313120685.png

 

 

Add a line chart, set Items to the following function and select Series.

AddColumns(Filter(List26,Year="2021") As Temp ,"Y2022",LookUp(Filter(List26,Year="2022"),Temp.Season=Season).Number)

In your database it should be:

AddColumns(Filter(‘A350 Withdrawal Count’,Year="2022") As Temp ,"Y2023",LookUp(Filter(‘A350 Withdrawal Count’ ,Year="2023"),Temp.Month=Month).Withdrawal Count’)

vxiaochenmsft_1-1670313120689.png

 

 

Set the number of Series to display.

vxiaochenmsft_2-1670313120690.png

 

Best Regards,

Wearsky

Kane2_0-1670313884191.png

The code doesn't seem to work? Any help with regards to this?

 

@v-xiaochen-msft Apologies it works now, just had some minor issues with my code. One last thing, is there a way I could possibly filter the chart based on the year using a dropdown per se, such as when the user selects 2022, it will only display the line for 2022, vice versa for 2023 and when the user selects all, the chart will then display both lines. Much appreciated!

 

v-xiaochen-msft
Community Support
Community Support

Hi @Kane2 ,

 

I made a sample for you:

 

Add a dropdown in app.

vxiaochenmsft_0-1670376359248.png

 

 

Set 'items' to the following function.

If(Dropdown1.Selected.Value="All",AddColumns(Filter('A350 Withdrawal Count',Year="2022") As Temp,"Y2023",LookUp(Filter('A350 Withdrawal Count',Year="2023"),Temp.Month=Month).'Withdrawal Count'),AddColumns(Filter('A350 Withdrawal Count',Year=Dropdown1.Selected.Value) As Temp,"Y2023",LookUp(Filter('A350 Withdrawal Count',Year="2022"),Temp.Month=Month).'Withdrawal Count'))

vxiaochenmsft_1-1670376359254.png

 

 

Set the number of Series to display.

If(Dropdown1.Selected.Value=”All”,2,1)

vxiaochenmsft_2-1670376359255.png

 

Best Regards,

Wearsky

Hi @v-xiaochen-msft  majority of this solution works, however, when I select 2023 in the drop down, the line chart does not change to the appropriate dataset. How do I rectify this issue?

@v-xiaochen-msft Apologies it works now, it was just a mistake on my part when I inputted the wrong series in order. Much appreciated!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,220)