Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ATYB9
New Member

Data slicing - multiple years

Hello,

 

I am fairly new to Power BI and I am trying to use slicer to apply in a dynamic way so that the visuals on the same page show the relevant data for the particular year.

 

See below my data from Excel file with two tabs (seem to be unable to attach the file for some reason):

 

Power BI report link 

Excel file link 

 

First tab "Summary details"

IDDraft/FinalEntity NameCurrency of dataPeriod End
Entity ABC 31/12/2021DraftEntity ABCGBP test 202131/12/2021
Entity ABC 31/12/2020DraftEntity ABCGBP test 202031/12/2020
Entity ABC 31/12/2019DraftEntity ABCGBP test 201931/12/2019
Entity DEF 30/06/2021DraftEntity DEFUSD test 202130/06/2021
Entity DEF 30/06/2020DraftEntity DEFUSD test 202030/06/2020
Entity DEF 30/06/2019DraftEntity DEFUSD test 201930/06/2019

 

Second tab: "Draft position"

IDHeading 1Heading 2Heading 3Heading 4Heading 5
Entity ABC 31/12/202199,999100,122100,245100,368100,491
Entity ABC 31/12/202098,99999,12299,24599,36899,491
Entity ABC 31/12/201997,99998,12298,24598,36898,491
Entity DEF 30/06/2021-2,0004,000-6,000-8,00010,000
Entity DEF 30/06/2020-1,0002,000-3,000-4,0005,000
Entity DEF 30/06/2019-5001,000-1,500-2,0002,500

 

 

 

As you can see, the visuals in the "Current selected year" column is working correctly however I am struggling to find the correct formula for the values in the "Prior year" column (circled in screenshot below in red) to produce the correct results. The prior year results should always be the current selected year minus 1 year. For example if the current selected year in the "Period End" slicer is 2021, then the Prior Year data should show for 2020 for the specific entity selected. 

 

Currently the Prior Year is showing the same as the Current selected year column which is incorrect. Many thanks in advance for your help!

 

ATYB9_0-1668108092782.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ATYB9 ,

I updated your sample pbix file, please find the detailed steps in the attachment.

1. Unpivot Heading1~Heading5 columns of the query 'Merge1'

yingyinr_0-1668148793685.png

2. Create a period dimension table(Don't create any relationship with Merge1 table)

yingyinr_1-1668149042912.png

3. Update the formula of measure [SelectedYear] as below

SelectedYear = SELECTEDVALUE('Period Ends'[Period End])

4. Create two measures to get the selected year and previous year heading values

CY_Headings =
CALCULATE (
    SUM ( 'Merge1'[Value] ),
    FILTER ( 'Merge1', 'Merge1'[Period End] = [SelectedYear] )
)
PY_Headings = 
CALCULATE (
    SUM ( 'Merge1'[Value] ),
    FILTER ( 'Merge1', 'Merge1'[Period End] = [PriorYearToSelectedYear] )
)

yingyinr_2-1668149304409.png

PS: After you open the attachment, please update the data source file directory with yours for the query "Summary details" and "Draft position"...

yingyinr_3-1668149521026.png

Best Regards

View solution in original post

2 REPLIES 2
ATYB9
New Member

Sorry forgot to thank you for this! It was very much appreciated!

Anonymous
Not applicable

Hi @ATYB9 ,

I updated your sample pbix file, please find the detailed steps in the attachment.

1. Unpivot Heading1~Heading5 columns of the query 'Merge1'

yingyinr_0-1668148793685.png

2. Create a period dimension table(Don't create any relationship with Merge1 table)

yingyinr_1-1668149042912.png

3. Update the formula of measure [SelectedYear] as below

SelectedYear = SELECTEDVALUE('Period Ends'[Period End])

4. Create two measures to get the selected year and previous year heading values

CY_Headings =
CALCULATE (
    SUM ( 'Merge1'[Value] ),
    FILTER ( 'Merge1', 'Merge1'[Period End] = [SelectedYear] )
)
PY_Headings = 
CALCULATE (
    SUM ( 'Merge1'[Value] ),
    FILTER ( 'Merge1', 'Merge1'[Period End] = [PriorYearToSelectedYear] )
)

yingyinr_2-1668149304409.png

PS: After you open the attachment, please update the data source file directory with yours for the query "Summary details" and "Draft position"...

yingyinr_3-1668149521026.png

Best Regards

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.