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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Vamshi2020
Helper II
Helper II

Display data for past 2 years from selected date in slicer

Hi All,

I have one Date Dimension Table and one Fact Table. Iam using year from Date Dimension table as slicer. My requirement is ,
what ever year i select in slicer, my fact table visual should show the data for past 24 months from selected year. I have assigned date in fact table, so data should show the past 24 months of assigned date.

FYI, Dim Date and Fact table are not related.

Please help me to achieve this.

 

TIA

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Vamshi2020 ,

 

Refer the following steps.

Create a measure like below.

Measure = 
var data_year = YEAR(SELECTEDVALUE('Table'[date]))
return
IF(data_year<=SELECTEDVALUE('date'[year])&&data_year>SELECTEDVALUE('date'[year])-2,1,0)

Add it to visual level filter.

The result would be shown as below.

17.PNG

18.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @Vamshi2020 ,

 

Refer the following steps.

Create a measure like below.

Measure = 
var data_year = YEAR(SELECTEDVALUE('Table'[date]))
return
IF(data_year<=SELECTEDVALUE('date'[year])&&data_year>SELECTEDVALUE('date'[year])-2,1,0)

Add it to visual level filter.

The result would be shown as below.

17.PNG

18.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

hi @v-jayw-msft , its not working for me.  

i have 2 tables....

-one is dimension table ('Table1' with Date column)

-second is fact table ('scurve with cummulative' with Date column)

-fact and dimension tables are connected via date columns

-my slicer has date column from table 1 

-my area chart has x axis & y-axis (date column & cummulative cost- both from 'scurve with cummulative' table)

- if i select a month (eg. september) from slicer...i want the graph to show values of semtember and all values before that month. Please help

 

yaseenhamid_0-1682754832088.pngyaseenhamid_1-1682754870017.png

 

 

I try to use but measure shown 1 on selected value only. Please advise me.

 

Measure = 
VAR YearSelection = SELECTEDVALUE(dim_Date[Year])
RETURN
IF(YearSelection <= MAX(vvip_bi_data_all[spend_year]) && YearSelection > MAX(vvip_bi_data_all[spend_year])-2, 1, 0)

 

 Screenshot 2022-08-10 190443.png

amitchandak
Super User
Super User

@Vamshi2020 ,  a measure like

2 year =
var _min = minx(allselected('Date'), 'Date'[Date])
var _max = maxx(allselected('Date'), 'Date'[Date])
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max))

Also REfer

https://www.youtube.com/watch?v=duMSovyosXE

@amitchandak ,

I want to restrict all the columns in Table visual to show data for past 24 months.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.