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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sumit626
Frequent Visitor

restricts months in al previous years till the last month selected in the date slicers

I want to restrict data of all previous years till the month last month selected in the date slicer suppose the last month selected is june 2021 in the date slicers so all the years should show data till June only
Screenshot 2023-04-24 185716.png

3 REPLIES 3
Sumit626
Frequent Visitor

Got the solution
Created a disconnected date table and used the following measure

Sales = 

CALCULATE(SUM(Orders[Sales]), MONTH(Orders[Order Date])<= MONTH(MAX('Table'[Date])))
amitchandak
Super User
Super User

@Sumit626 , If you need lytd

 

LYTD =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(Date(Year(_max1)-1, Month(_max1), Day(_max1)),-1)
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

if you want control measure till last year

 

LYTD =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(Date(Year(_max1)-1, Month(_max1), Day(_max1)),-1)
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,filter(Date,'Date'[Date]>= _min &&  'Date'[Date]<= _max))

I need all the previous year not just the last year

And reference should not be today() it should be the max month selected in date slicer

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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