Forum Discussion
Visualizations with different filters
- 5 years ago
Hi weeksd ,
The example I have used is just on some mockup data I have and based on months has I reported, so each month have is own bar chart.
In Power BI you can achieve this by using a measure has I refered previously or using the samll multiples making a filter based on the information.
In Power BI calculations are based on context meaning that filters, columns, others visualizations and so on influence the result of your visualizations. This also means that the way you have your data setup also impacts the calculations.
If you unpivot your data you will only need a single measure for the previous year calculation, however if you keep your model with the A, B and C column you will need to have more than one measure.
For using the small multiples you just need to adjust to show the last 2 years.
I have pickup your data again and made a small file with both options, I also added 2019 data to have the filtering. Also only have to slicers but you can had has many has you need.
Using the previous year measure you need to have the use of 3 measures:
Previous Year A = CALCULATE(SUM(DATA[A]),FILTER(ALL(DATA[Year]), DATA[Year]= MAX(DATA[Year]) -1)) Previous Year B = CALCULATE(SUM(DATA[B]),FILTER(ALL(DATA[Year]), DATA[Year]= MAX(DATA[Year]) -1)) Previous Year C = CALCULATE(SUM(DATA[C]),FILTER(ALL(DATA[Year]), DATA[Year]= MAX(DATA[Year]) -1))Result is below:
Using the small multiples you need to create a table or the years and a measure for the filter:
TABLE Years = DISTINCT(DATA[Year]) YearFilter = if(VALUES(DATA[Year]) <= MAX(Years[Year]) && VALUES(DATA[Year]) >= MAX(Years[Year]) -1 , 1)Now use the year from the new table has you slicer and the Yearfilter on your visualization setting up the value for non blank values:
Check PBIX file attach.
Believe that probably I'm not understanding your request but be aware that the interactions between your visualizations and your measures and calculations is very important in Power BI and this concept makes all the difference between the results.
If I can assist in any other way please tell me.
Hi weeksd,
Did MFelix 's suggest help for your scenario? If that is the case, you can consider Kudo or accept his suggestion to help others to find this more quickly.
If not, please provide some more information to help us test on them.
Regards,
Xiaoxin Sheng
Sorry all but I cannot reply yet to individual posts. In my data example, I forgot to add in a column.
So the data would be more like. Columns a, B and C are already totaled whne coming from the database.
Year Week Product A B C
2020 1 XYZ 7 8 7
2020 1 DEF 7 8 7
2020 2 XYZ 7 8 7
2020 3 DEF 7 8 7
2020 3 GHI 7 8 7
2020 3 XYZ 7 8 7
2021 1 XYZ 7 8 7
2021 1 DEF 5 6 6
2021 2 XYZ 3 9 9
2021 2 DEF 7 8 7
2021 3 DEF 10 18 17
2021 3 GHI 17 18 17
2021 3 XYZ 7 8 7
Again the top visualization would be a column chart for the 2021 datawhere the weeks are one column set showing the products for that week. The second visualization would be for 2020 and look the same as the top visual.
- MFelix5 years agoSuper User
Hi weeksd ,
The calculation need to be done has I refered in my previous post, the number of columns is not an issue since the comparision is only on the year column.
However I once again enphatize the question about your ABC columns, they should be unpivot if the information is not related to each other however if this information is based on fields that are related for example quantities, sales and cost you must create a measure for each column:
Preivous Year = CALCULATE(SUM(DATA[A]),FILTER(ALL(DATA[Year]), DATA[Year]= MAX(DATA[Year]) -1))- weeksd5 years agoFrequent Visitor
As it seems that my help request answers are not what I actually require I am closing this as un-resolved. Thanks all
- MFelix5 years agoSuper User
Hi weeksd ,
Have you tried using the small multiples on the visualization to create the multiples charts without making more than one visualization?
https://powerbi.microsoft.com/en-us/blog/announcing-small-multiples-public-preview/