Forum Discussion
Selected Year and Previous Year
Hello Everyone,
I have 3 columns in my data: Finished year, Project cost, Project name.
My requirement is
Finished year slicer --2021 I selected
The
column chart should show the ---- 2020,2021 in the x-axis with project cost as a Y Axis.
Please help me out with this issue.
Regards,
Ramana PC
Hi Raman3456 please try this
you can create disconnected table year as this
YearSelector =
DISTINCT ( SELECTCOLUMNS ( 'Calendar', "Year", 'Calendar'[Year] ) )And measure as this Selected & Previous Year Cost =
VAR SelectedYear = SELECTEDVALUE('YearSelector'[Year])
RETURN
IF (
SELECTEDVALUE('Calendar'[Year]) IN {SelectedYear, SelectedYear - 1},
[Total Project Cost measure]
)
7 Replies
- johnt75
Super User
You'll need a proper date table, and then you can use the principles outlined in https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/
- johnt75
Super User
Set up the 2 date tables as they do in the article / video, but when creating the calculation item instead of using 6 months use 12 instead.
To create the relationship from date to your table, add a new calculated column as
Finished Date = DATE( 'Table'[Finished Year], 1, 1)and then create a one-to-many single direction relationship from 'Date'[Date] to 'Table'[Finished Date].
In the slicer, use the year column from the date table. On the chart use the year column from previous date.
- techies
Super User
Hi Raman3456 please try this
you can create disconnected table year as this
YearSelector =
DISTINCT ( SELECTCOLUMNS ( 'Calendar', "Year", 'Calendar'[Year] ) )And measure as this Selected & Previous Year Cost =
VAR SelectedYear = SELECTEDVALUE('YearSelector'[Year])
RETURN
IF (
SELECTEDVALUE('Calendar'[Year]) IN {SelectedYear, SelectedYear - 1},
[Total Project Cost measure]
) - v-prasare
Community Support
Hi Raman3456, As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?
johnt75&techies Thanks for your promt response.
Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query
- v-prasare
Community Support
Hi Raman3456,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?
Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query
- v-prasare
Community Support
Hi Raman3456,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?
Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query