Forum Discussion
matrix for next three year data
Hi All,
I want to show in a matrix next three years' data (current, +1, +2). For example; if the slicer is selected 09.2020 then the matrix should show the data for 2020,2021 and 2022. Similarly, if 09.2019 is selected then the years should be 2019, 2020, 2021.
I have the following example data.
| Year | Cat | Reg | Month | Value1 | BP |
| 2019 | Ca1 | R1 | 09.2020 | 5 | |
| 2019 | Ca2 | R1 | 09.2020 | 6 | |
| 2020 | Ca1 | R1 | 09.2020 | 10 | |
| 2020 | Ca2 | R1 | 09.2020 | 12 | |
| 2021 | Ca1 | R1 | 09.2020 | 14 | |
| 2022 | Ca1 | R1 | 09.2020 | 20 | |
| 2022 | Ca2 | R1 | 09.2020 | 22 | |
| 2019 | Ca1 | R2 | 09.2020 | 7 | |
| 2019 | Ca2 | R2 | 09.2020 | 8 | |
| 2020 | Ca1 | R2 | 09.2020 | 12 | |
| 2020 | Ca2 | R2 | 09.2020 | 13 | |
| 2021 | Ca1 | R2 | 09.2020 | 16 | |
| 2022 | Ca1 | R2 | 09.2020 | 24 | |
| 2022 | Ca2 | R2 | 09.2020 | 26 | |
| # | # | R1 | 09.2020 | 120 | |
| # | # | R2 | 09.2020 | 300 | |
| 2018 | Ca1 | R1 | 09.2019 | 9 | |
| 2018 | Ca2 | R1 | 09.2019 | 19 | |
| 2019 | Ca1 | R1 | 09.2019 | 10 | |
| 2019 | Ca2 | R1 | 09.2019 | 12 | |
| 2020 | Ca1 | R1 | 09.2019 | 14 | |
| 2024 | Ca1 | R1 | 09.2019 | 20 | |
| 2024 | Ca2 | R1 | 09.2019 | 22 | |
| 2018 | Ca1 | R2 | 09.2019 | 7 | |
| 2018 | Ca2 | R2 | 09.2019 | 8 | |
| 2019 | Ca1 | R2 | 09.2019 | 12 | |
| 2019 | Ca2 | R2 | 09.2019 | 13 | |
| 2021 | Ca1 | R2 | 09.2019 | 16 | |
| 2023 | Ca1 | R2 | 09.2019 | 24 | |
| 2023 | Ca2 | R2 | 09.2019 | 26 | |
| # | # | R1 | 09.2019 | 220 | |
| # | # | R2 | 09.2019 | 400 |
Second question: is it possible to add BP value to the end of the matrix?
The file is available at:
https://www.dropbox.com/s/u190j3uvqhqdzq5/Q_Peg_next%20three%20years.pbix?dl=0
Thanks in advance.
Hi, IF
Sorry, I can't solve it currently.
Just as you can’t directly add the “BP” column to the end of the matrix, it’s also difficult for you to create a row "perc" under "total"
Hope someone can provide a good workaroud.Best Regards,
Community Support Team _ Eason
5 Replies
- amitchandak
Super User
IF , You can use relative date slicer
https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
or refer to this approach https://www.youtube.com/watch?v=duMSovyosXE
- IF
Post Prodigy
Hi,
Thanks for the answer. However, I can use "relative" option only for date formated slicers, I believe. My field is text formated such as "09.2020", "09.2019", etc. "mm.yyyy". I have data for last 40 months. Therefore I can not use filter either.
I hope there is a solution for this.
Regards,
- v-easonf-msft
Community Support
Hi, IF
Since your "year" column is of text type, it is recommended to create a date type "year" column first:
Year(Date) = IF(ISERROR(DATE('Table'[Year],1,1)),BLANK(),DATE('Table'[Year],1,1))Then please try measure as below t0 replace the original field "Value1":
value2 = VAR _sel = SELECTEDVALUE ( 'Table'[Month] ) VAR _year = VALUE ( RIGHT ( _sel, 4 ) ) VAR b = CALCULATE ( SUM ( 'Table'[Value1] ), FILTER ( 'Table', YEAR ( 'Table'[Year(Date)] ) <= _year + 2 && YEAR ( 'Table'[Year(Date)] ) >= _year ) ) RETURN IF ( ISFILTERED ( 'Table'[Month] ), b, SUM ( 'Table'[Value1] ) )Then result will show as below:
Please check attached pbix file for more details.
For you Second question, I'm afraid that it‘s impossible to add BP value to the end of the matrix.You need to create another table visual to show it.
Best Regards,
Community Support Team _ Eason- IF
Post Prodigy
Hi,
Thanks. The file works well. Is it possible to show both percentage and total at the same time?
Regards,
- v-easonf-msft
Community Support
Hi, IF
Sorry, I can't solve it currently.
Just as you can’t directly add the “BP” column to the end of the matrix, it’s also difficult for you to create a row "perc" under "total"
Hope someone can provide a good workaroud.Best Regards,
Community Support Team _ Eason