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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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