Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Date Range Expressions

Simple but powerful expressions to quickly filter data. I use them often by storing these values on a 'DateRangeExpression' Property Control and passing the expression directly to the 'Data Limited by Expression' option: ${DateRangeExpression}



-
Today[Date]=Date(DateTimeNow())
Last 30 Days[Date] >= dateadd('dd',-30,DateTimeNow())
This WeekWeek([Date]) = week(DateTimeNow()) and Year([Date]) = year(DateTimeNow())
This MonthMonth([Date]) = month(DateTimeNow()) and Year([Date]) = year(DateTimeNow())
Year to DateYear([Date]) = Year(DateTimeNow())
Last Month
Last 12 Months
Month([Date]) = Month(dateadd('mm',-1,DateTimeNow())) and Year([Date]) = Year(dateadd('mm',-1,DateTimeNow()))
[Date] >= dateadd('mm',-12,DateTimeNow())
Q1Quarter([Date]) = 1 and Year([Date]) = Year(DateTimeNow())
Q2Quarter([Date]) = 2 and Year([Date]) = Year(DateTimeNow())
Q3Quarter([Date]) = 3 and Year([Date]) = Year(DateTimeNow())
Q4Quarter([Date]) = 4 and Year([Date]) = Year(DateTimeNow())
Begining of MonthDate(Year(DateTimeNow()),Month(DateTimeNow()),1)
End of MonthDateAdd('day',-1,date(Year(DateTimeNow()),Month(DateAdd('month',1,DateTimeNow())),1))
End of Last MonthDateAdd("day",-1,date(Year(DateTimeNow()),Month(DateTimeNow()),1))
End of Next MonthDateAdd("day",-1,date(Year(DateTimeNow()),Month(DateAdd("month",2,DateTimeNow())),1))
First Weekending of the yearDateadd("day",6 - DayOfWeek(DATE(Year(DateTimeNow()),1,1)), DATE(year(DateTimeNow()),1,1))
Last Weekending (last saturday)DateAdd("week",Week(DateTimeNow()) - 2,Dateadd("day",6 - DayOfWeek(DATE(Year(DateTimeNow()),1,1)),DATE(year(DateTimeNow()),1,1)))
End of this weekDateAdd("week",Week(DateTimeNow()) - 1,Dateadd("day",6 - DayOfWeek(DATE(Year(DateTimeNow()),1,1)),DATE(year(DateTimeNow()),1,1)))
End of next weekDate(DateAdd("week",Week(DateTimeNow()),Dateadd("day",6 - DayOfWeek(DATE(Year(DateTimeNow()),1,1)),DATE(year(DateTimeNow()),1,1))))
Previous Quarter end dateDateAdd("day",-1,DateAdd("quarter",Quarter(DateTimeNow()) - 1,Date(Year(DateTimeNow()),1,1)))
--

4 comments:

Anonymous said...

Great help. Thanks!

Unknown said...

I'm trying to apply the functionality, but after creating in "Document Properties -> Properties (after New), I put the function of what type? I've tried date, string, integer, but when I apply the function in" Data Limited Expression ", that this the Properties is "Boolean Type", how do you make this?

If possible, can you forward the step by step?

Regards,


Vanice

Jose Leviaguirre said...

Hello Vanice,

You can use these expressions directly on the 'Data Limited by' in your visualization properties > Data > Data Limited by and type the expression. For exampl,e if you want to see only the last 30 days, just put:

[yourDatecoumn] >= dateadd('dd',-30,DateTimeNow())

Noah Glenn said...
This comment has been removed by the author.