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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
y5famfnatudu
Resolver I
Resolver I

Get records from current & previous year, when only current year selected

Hello,

 

I would appreciate it so much if you can help me here please.

I would like to select a year from a slicer, but the records from the Selected year & records from Previous year to be shown. How can I achieve something like that?

y5famfnatudu_0-1675350222172.pngy5famfnatudu_1-1675350230157.png

Best regards,

Simon

 

 

1 ACCEPTED SOLUTION

Thank you so much @FreemanZ 

Unfortunately, this didn't work for me, as the Date Table is realted to Orders, and other tables in the dashboard.

Do you think it's still possible to tweak the measure please so that it shows the selected year and the previous one? Your help is so much appreciated.

 

Best regards,

Simon

View solution in original post

5 REPLIES 5
FreemanZ
Super User
Super User

hi @y5famfnatudu 

you can try like:

Measure =

CALCULATE([...], EDATE(TableName[Date], -12))

 

or if you have dedicated date table, try Time Intelligence functions, like:

CALCULATE([...], DATEADD(TableName[Date], -1, YEAR))

CALCULATE([...], SAMEPERIODLASTYEAR(TableName[Date]))

and many more.

Hi @FreemanZ ,

 

But I don't need measures to calculate anything, I just need a table visual to show the records belonging to the selected year & previous year, as shown in the screenshot above.

 

Thank you,

Simon

hi @y5famfnatudu 

supposing you have two unrelated tables like:

FreemanZ_0-1675389201302.png

FreemanZ_1-1675389214069.png

 

1) plot a table visual with all the columns from the first table, choose "don't summarize" for every column. 

2) write a measure like:

 

YearFilter = 
VAR _year = SELECTEDVALUE(Year[Year])
RETURN
IF(
    YEAR(MAX(TableName[OrderDate])) IN {_year, _year-1},
    1,0
 )

 

3) feed the measure to the filter pane for the table visual and choose 1

 

it worked like this:

FreemanZ_3-1675389626140.pngFreemanZ_4-1675389650298.png

 

 

Thank you so much @FreemanZ 

Unfortunately, this didn't work for me, as the Date Table is realted to Orders, and other tables in the dashboard.

Do you think it's still possible to tweak the measure please so that it shows the selected year and the previous one? Your help is so much appreciated.

 

Best regards,

Simon

hi   @y5famfnatudu

 

The measue could be tweaked to ignore the slicer, but you still have orderdate columns, which are anyway filtered by the Year slicer. 

 

So in cases like this, try to create an small independent table for the year slicer. 

You may import one from excel, create one from Power Query Editor, or with DAX code like:

Year =
SELECTCOLUMNS(
    {2022, 2023},
    "Year", [Value]
)

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.