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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
achanikya
Helper I
Helper I

Rolling 12 YY-Month

Hi Team, 

i want to display sales amount for last 12 Completed month in Line Chart.

 

For Example:

If january 2022 once Came, that time line chart should show the data From Feb-2021 To Jan -2022. Only 12 MOnths

 

Please advice some measures  for displaying completed 12 Months of data.

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

Hi @achanikya ,

 

If the last 12 months are always based on current date, you could simply use Relative Date filter as shown below:

 

2/11/2021-1/10/2022

Eyelyn9_1-1641794362282.png

 

Or if you want to dynamically change it based on date selection in slicer, please firstly create a date table for slicer, and then create a measure for filter:

ForSlicer = VALUES('Table'[Date])
Measure = 
var _date= DATE(MAX('ForSlicer'[Date].[Year]), MAX('ForSlicer'[Date].[MonthNo]),1)
var _diff= DATEDIFF(MAX('Table'[Date]),_date,MONTH)
return IF(_diff>=0&& _diff<12,1,0)

2021/2/1-2022/1/10

 

Eyelyn9_2-1641794422907.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @achanikya ,

 

If the last 12 months are always based on current date, you could simply use Relative Date filter as shown below:

 

2/11/2021-1/10/2022

Eyelyn9_1-1641794362282.png

 

Or if you want to dynamically change it based on date selection in slicer, please firstly create a date table for slicer, and then create a measure for filter:

ForSlicer = VALUES('Table'[Date])
Measure = 
var _date= DATE(MAX('ForSlicer'[Date].[Year]), MAX('ForSlicer'[Date].[MonthNo]),1)
var _diff= DATEDIFF(MAX('Table'[Date]),_date,MONTH)
return IF(_diff>=0&& _diff<12,1,0)

2021/2/1-2022/1/10

 

Eyelyn9_2-1641794422907.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@achanikya , if you have not selected a date then

 

//Last 12 based on today
new measure =
var _max = eomonth(today(),0)
var _min = eomonth(today(),-12)+1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

Assumes you are using joined date table.

 

But if you filtered Jan 21 and then want 12 months you need an independent date table

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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