Skip to main content
Announcements
WEBINAR April 23, 2025: Iceberg Ahead: The Future of Open Lakehouses - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I minus 12 months from a DATE?


Hi,

I want to count the number of activities performed in an Account within 12 months from the accounts expiry period.  I have a field date called Renewal and my thought was to use that and minus 12 months from it - but unsure on how to do this.  My current expression below gives me everything and I have to use a calendar slider to select the right data - as below:

count ({<Mandatory = {'1'}, Delivered = {'*'} - {'0'}, DeliverDate -= {'0'}>}distinct Account & CSP_Name)

I also have the following Master Calender if that helps:


MasterCalendar:
Load

TempDate AS Renewal,

week(TempDate) As EndWeek,

Year(TempDate) As EndYear,

Month(TempDate) As EndMonth,

Day(TempDate) As EndDay,

YeartoDate(TempDate)*-1 as EndCurYTDFlag,

YeartoDate(TempDate,-1)*-1 as EndLastYTDFlag,

inyear(TempDate, Monthstart($(varMaxDate)),-1) as EndRC12,

date(monthstart(TempDate), 'MMM-YYYY') as EndMonthYear,

ApplyMap('QuartersMap', month(TempDate), Null()) as EndQuarter,

Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as EndWeekYear,

WeekDay(TempDate) as EndWeekDay

Thanks for any help.

Cheers.

1 Solution

Accepted Solutions
SergeyMak
Partner Ambassador

The simple way is use function AddMonths(ourDateField, -12)

But I don't understand clearly your requirements

Regards,
Sergey

View solution in original post

2 Replies
SergeyMak
Partner Ambassador

The simple way is use function AddMonths(ourDateField, -12)

But I don't understand clearly your requirements

Regards,
Sergey
nirav_bhimani
Partner - Specialist

Hi,

Try this Expression,

Count({<Mandatory = {'1'}, Delivered = {'*'} - {'0'}, DeliverDate -= {'0'},CalDate={">$(=addyears(max(CalDate),-1))<=$(=max(CalDate))"},CalYear=,CalMonth=,CalQuarter=>}distinct Account & CSP_Name)


Regards,

Nirav Bhimani