Forum Discussion
Bar chart visualization for different years
Hello!
I believe there should be a rather easy solution for this, but for some reason, I haven't been able to do this
I have a list of products with the launching year and the year they will be discontinued.
I want a bar chart where my horizontal axis is the timeframe and the data being the count of products that will be launched (in one bar) and the products that will be discontinued in another bar.
| Product | Launched | Discontinued |
| Socks | 2021 | 2023 |
| Blouse | 2009 | 2021 |
| Pants | 2020 | 2021 |
| Jacket | 2019 | 2040 |
| Hairband | 2020 | 2022 |
| T-shirt | 2020 | 2024 |
| Gloves | 2008 | 2009 |
Does anyone have an idea on how to do this bar chart visualization?
It will be much appreciated!
You'll need a new table to use for the x-axis.
For example:
Years = SELECTCOLUMNS ( GENERATESERIES ( MIN ( Products[Launched] ), MAX ( Products[Discontinued] ) ), "Year", [Value] )This is just a list of years between 2008 and 2040.
Put Years[Year] on the x-axis and define your counting measures.
LaunchedCount = CALCULATE ( COUNTROWS ( Products ), Products[Launched] IN VALUES ( Years[Year] ) ) DiscontinuedCount = CALCULATE ( COUNTROWS ( Products ), Products[Discontinued] IN VALUES ( Years[Year] ) )
3 Replies
- AlexisOlsonSuper User
You'll need a new table to use for the x-axis.
For example:
Years = SELECTCOLUMNS ( GENERATESERIES ( MIN ( Products[Launched] ), MAX ( Products[Discontinued] ) ), "Year", [Value] )This is just a list of years between 2008 and 2040.
Put Years[Year] on the x-axis and define your counting measures.
LaunchedCount = CALCULATE ( COUNTROWS ( Products ), Products[Launched] IN VALUES ( Years[Year] ) ) DiscontinuedCount = CALCULATE ( COUNTROWS ( Products ), Products[Discontinued] IN VALUES ( Years[Year] ) )- AnonymousNot applicable
- AnonymousNot applicable
Hi AlexisOlson, a quick follow-up question on this.
How can I create a measure of "active" products per year?
Something like the summing the total number of launched products from previous years that haven't been discontinued, and substracting the discontinued per year.
Do I have to create a measure for each year? Or could I have a general one and then add a yearly slicer to my page?
Any tip will be appreciated!