Forum Discussion
% difference between years for average sales
not really, the difference could be any year vs any year (as chosen in the slicer)
So the viewer could select 2019 and 2021. or 2018 and 2019. or any other combo that they want to see the % difference for.
- FreemanZ3 years ago
Super User
so in any selection, the difference is a single value, why being plotted with year on the x axis?
- mfarali3 years agoFrequent Visitor
the difference is a single value if only 2 years are selected. but if the viewer wants to see the trend then they can select more than 2 years to see the changes in %
like choosing to see 2018, 2019, 2020 if they wanted to
- v-xiaosun-msft3 years ago
Community Support
Hi mfarali
According to your description, I made a sample and here is my solution. Please follow these steps.
Sample data:
Create five columns to calculate totals.
Totals = SUM('Tabelle1'[values])sum of 2018 = SUMX(FILTER('Tabelle1','Tabelle1'[Year]=2018),'Tabelle1'[values])sum of 2019 = SUMX(FILTER('Tabelle1','Tabelle1'[Year]=2019),'Tabelle1'[values])sum of 2020 = SUMX(FILTER('Tabelle1','Tabelle1'[Year]=2020),'Tabelle1'[values])sum of 2021 = SUMX(FILTER('Tabelle1','Tabelle1'[Year]=2021),'Tabelle1'[values])Create a calculated column to return the % of each year.
percentage = IF('Tabelle1'[Year]=2018,'Tabelle1'[sum of 2018]/'Tabelle1'[Totals], IF('Tabelle1'[Year]=2019,'Tabelle1'[sum of 2019]/'Tabelle1'[Totals], IF('Tabelle1'[Year]=2020,'Tabelle1'[sum of 2020]/'Tabelle1'[Totals], IF('Tabelle1'[Year]=2021,'Tabelle1'[sum of 2021]/'Tabelle1'[Totals]))))Then create a column to return the changes.
change = IF ( 'Tabelle1'[Year] = 2018, 0, 'Tabelle1'[percentage] - CALCULATE ( MAX ( 'Tabelle1'[percentage] ), FILTER ( 'Tabelle1', 'Tabelle1'[percentage] < EARLIER ( Tabelle1[percentage] ) ) ) )Finally, put "Year" and "change" into the line chart, you will get the result as below.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ xiaosunIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.