COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Laynlowz on 09 Jun 2023 02:35:16 PM

Title: calculation for previous month
Post by: Laynlowz on 09 Jun 2023 02:35:16 PM
hello

how would i do a calculation for the last month? I was thinking of doing a last 31 days which would work out if it was February 1st and I was pulling all of january, but come March 1st that would not work.
i found a formula that is very close to working but for some reason it never include May 31st when I try to pull May data. any ideas what I could change? any examples of a formula would be extremely helpful because I am still learning date filters.

[Performance and Throughput].[Event Summary Header].[Facility - Event Start Date Time] between _first_of_month(_add_months(current_date, -1)) and _add_days(_first_of_month(current_date), -1)
Title: Re: calculation for previous month
Post by: MFGF on 09 Jun 2023 03:34:51 PM
Quote from: Laynlowz on 09 Jun 2023 02:35:16 PM
hello

how would i do a calculation for the last month? I was thinking of doing a last 31 days which would work out if it was February 1st and I was pulling all of january, but come March 1st that would not work.
i found a formula that is very close to working but for some reason it never include May 31st when I try to pull May data. any ideas what I could change? any examples of a formula would be extremely helpful because I am still learning date filters.

[Performance and Throughput].[Event Summary Header].[Facility - Event Start Date Time] between _first_of_month(_add_months(current_date, -1)) and _add_days(_first_of_month(current_date), -1)

Have you tried

[Performance and Throughput].[Event Summary Header].[Facility - Event Start Date Time] between _first_of_month(_add_months(current_date, -1)) and _last_of_month(_add_months(current_date, -1))

Cheers!

MF.