if year equals current year then calendar month to current month in cognos report studio - cognos

I have created a report with a slider that filters on year. The client however would like to not see the future month zero values. I am not quite sure how to modify the year and month filters so that if [fiscal year] = (year(current_date) then [Fiscal Year Month Number] to (month(current_date) I have attached a couple of screenshots. "Period" in the X axis is sorted by Fiscal Year and Fiscal Year Month Number.enter image description here
Thank you

I was trying to add this as a filter when I should have added it as a new measure.
if([Fiscal Year]=[Current Year] and [Fiscal Year Month #]<=[Current Month]) then ([Corp FY Data])
else
if([Fiscal Year]=[Current Year] and [Fiscal Year Month #]>[Current Month]) then (null)
else
if([Fiscal Year]>[Current Year]) then (null)
else
if([Fiscal Year]<[Current Year]) then ([Corp FY Data]) else (0)
Problem resolved. Yeah me. ;)

Related

Using pandas, how can I find out if my customer made a purchase last month or two months ago?

I'm new to python and new to pandas. Of course, if my project used exact dates, I could easily do this, but unfortunately, the date type is a little different, and as you can see, the sign 08 is after the year 1401, which means it is the eighth month of the year 1401.
I currently know that these 3 customers have bought from me this month. But I want to know if these 3 customers bought from me in the previous month or two months ago? If they do, I will give them a discount.
Of course, I should also say that the number 08 is not always fixed, but it could be 09 in the next month. I just want to know if they bought from me 1 month ago or not?
According to the picture, now only Sara should get a discount
You could convert the purchase date to an integer and calculate the number of months from there.
For instance, you have the purchase month 1901/07 and you want to know in 1901/08 how many months the last purchase took place. So you convert both values to integers and subtract them (190108 - 190107 = 1).
import pandas as pd
df = pd.DataFrame({'customer': ['david', 'sara'], 'date': ['1901/03', '1901/07']})
# Manually setting the reference month (190108 for Year 1901 and Month 08)
df['months'] = 190108 - df['date'].replace('/', '', regex=True).astype(int)
# Check if eligible for discount
df['discount'] = df['months'].isin([1, 2])
customer
date
months
discount
0
david
1901/03
5
False
1
sara
1901/07
1
True
To compare with today's month you could to the following:
df['months'] = int(pd.Timestamp.now().strftime('%Y%m'))\
- df['date'].replace('/', '', regex=True).astype(int)

how to calculate the number of network days between 2 dates that are always with a fiscal year

Hi i am looking for some help to see the number of network days between 2 dates and again between a fiscal year on excel#
say for example if the fiscal year starts from april to march
the start date : 1/03/2022 and the end date 30/06/2022
thank you
=NETWORKDAYS(MAX(fiscal year start date, Employee start date),MIN(employee end date, fiscal year end date)))

Cognos Report Studio Monthly date

I need to calculate a logic on the basis of Weekending Date in a report for the Monthly report
We have two pages of reports in the report studio
Weekly Report with the weekending data (Example: 26/02/2021) Day 1 of the week starts from Saturday to Friday
Monthly Report with the month data. I know the monthly calculation to get the data current month data using the below
TRANSACTION_DATE between _first_of_month (_add_months (current_date,0) and _last_of_month (_add_months (current_date, 0)
But here the requirement is how can we calculate based on the Weekending Date. The requirement is to show the previous month data even in the 1st week of next month (New Month)
that is from (01-Mar-2021 to 05-Mar-2021) since the weekending of the weekly report is showing the data for 26/02/2021 (Friday).
This should work dynamically since this is a scheduled report and we are not having any prompt page to select the date ranges since the report take to long to execute.
Please share your ideas and thoughts on this.
Your help is much appreciated.
Yours Sincerely
Cognos Man
We need to know
day of the week
first week of the month
current week
prior month range
current month range
For the example, we will refer to the transaction data item as [Date]
To get the week, we are going to create a data item [Week of Year] like this:
_week_of_year ([Date])
To compare, we are going to create a data item [First of Month]
_first_of_month (Current_date)
That will allow us to create another data item [First of Month Week]
_week_of_year ([First of month])
Almost there, we need the day of the week [DOW]
_day_of_week (Current_Date,1)
We can create a data item just to make the filter a little easier, let's call it [Test] with an expression like this:
IF ([Week of Year] = [First of Month Week] and [DOW] < 6)Then('Prior')Else('Current')
Now we can create a filter
([Test] = 'Prior' AND
[Date] between [Prior Month Start] and [Prior Month End])
OR
(([Test] <> 'Prior' AND
[Date] between [Current Month Start] and [Current Month End])
To get the starting points:
[Current Month Start] definition would be
_first_of_month (Current_date)
[Current Month End] definition would be
_add_days (_first_of_month (_add_months(Current_date,1)),-1)
Prior month would be similar, just reduce the month, to get PrevDate
_add_months (Current_date, -1)
For example, [Prior Month Start]:
_first_of_month ([PrevDate])
For example, [Prior Month End]:
_add_days (_first_of_month (_add_months([PrevDate],1)),-1)

Excel work out fiscal year

The fiscal year starts on July 1 and ends on June 30th.
I need to calculate the fiscal year + month in the following format
26/05/2006 2005011
26/05/2006 2005011
09/06/2006 2005012
15/06/2006 2005012
My current formula is below.
=YEAR(A2)&"0"&MOD(MONTH(A2)-7,12)+1
The problem is that the formula populates the current year and not based on the fiscal year.
25/05/2006 2006011
26/05/2006 2006011
26/05/2006 2006011
09/06/2006 2006012
15/06/2006 2006012
Use EDATE()
=YEAR(EDATE(A1,-6)) & "0" & TEXT(MONTH(EDATE(A1,-6)),"00")
you need to do a check for the current date to see if it is before or after your breakpoint of june 30/july 1st.
=IF(A2<=Date(year(A2),6,30),Year(A2)-1,Year(A2))&"0"&MOD(MONTH(A2)-7,12)+1
So after you determine if you need to subtract 1 from your year or not, tack on the rest of your formula.

Change the date to fiscal year

I want to write a function in Excel to change the date. The logic is like this: if the month is (Jan, Feb or March) the result show me one year past (-1 year) and if the month is (April to -December) the result show the current year (which year the date shows).
example: if date is 02,Jan,2012 the result show me 2011 else show me 2012.
=IF(MONTH(G3) >=4, YEAR(G3), YEAR(G3) - 1) where G3 is the date to test, is one way.
Please try:
=IF(OR(MONTH(A1)=1,MONTH(A1)=2,MONTH(A1)=3),2011,2012)
With 02-Jan-2012 in A1 try,
=YEAR(A1)-(MONTH(A1)<4)
For a full date use one of these,
=DATE(YEAR(A1)-(MONTH(A1)<4), MONTH(A1), DAY(A1))
=EDATE(A1, -(MONTH(A1)<4)*12)
To extract fiscal year use:
=YEAR(A1) + IF(MONTH(A1)>=4,1,0)
I think in your case you would need:
=YEAR(A1) - IF(MONTH(A1)>=4,0,1)
If the months is before 4th month then subtract 1 year, else keep the same year. I wouldn't convert it to a full date DD/MM/YYYY with a 1 year subtracted, to avoid confusion keep it as year only YYYY.
Already plenty of answers, but thought I'd throw another one up:
=YEAR(DATE(YEAR(A1),MONTH(A1)-3,DAY(A1)))

Resources