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

View all the Fabric Data Days sessions on demand. View schedule

Reply
sshiny
Helper II
Helper II

Issue with Date function

My data is filtered when I hardcode as shown below.

 

Table =

VAR DateStart = DATE("2022", "11", "1")
VAR DateEnd = DATE("2023", "1", "5")

RETURN
  CALCULATETABLE(
      'Recorded Orders Fact',
      FILTER('Recorded Orders Fact','Recorded Orders Fact'[Order Date] <= DateEnd && 'Recorded Orders Fact'[Order Date] >= DateStart)
  )
 
But, I am unable to get the filtered data when I was the function TODAY(), MAX or LASTDATE. Please help me find the DAX . The below code does not filter the data.
Table =

VAR DateStart = MAX('Recorded Orders Fact'[Order Date])
VAR DateEnd   = MAX('Recorded Orders Fact'[Order Date]) - 30

RETURN
  CALCULATETABLE(
      'Recorded Orders Fact',
      FILTER('Recorded Orders Fact','Recorded Orders Fact'[Order Date] <= DateEnd && 'Recorded Orders Fact'[Order Date] >= DateStart)
  )
2 REPLIES 2
Mahesh0016
Super User
Super User

@sshiny 
Table =

 

VAR DateStart = MAX('Recorded Orders Fact'[Order Date])
VAR DateEnd   = MAX('Recorded Orders Fact'[Order Date]) - 30

 

RETURN
  CALCULATETABLE(
      'Recorded Orders Fact',
      FILTER('Recorded Orders Fact','Recorded Orders Fact'[Order Date] <=DateStart  && 'Recorded Orders Fact'[Order Date] >=DateEnd )
  )

*If this post helps, please consider accept as solution to help other members find it more quickly and Appreciate your Kudos.

amitchandak
Super User
Super User

@sshiny , Change position of start and end , start should be smaller

 

VAR DateEnd = MAXX(allselected('Recorded Orders Fact'),'Recorded Orders Fact'[Order Date])
VAR DateStart = MAXX(allselected('Recorded Orders Fact'),'Recorded Orders Fact'[Order Date]) - 30

RETURN
CALCULATETABLE(
'Recorded Orders Fact',
FILTER('Recorded Orders Fact','Recorded Orders Fact'[Order Date] <= DateEnd && 'Recorded Orders Fact'[Order Date] >= DateStart)
)

 

If needed use allselected

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

Top Solution Authors
Top Kudoed Authors