Pivot table Sort month for different years - excel

Hi I am pivoting data grouped by months. The months are spanned across 2 years with the start date being in july 2018 going back to august 2017. However when i try to sort the data, it always start with Jan 2018 first and goes alphabetically. How can i make it do chronologically. Also is there a way to change the date to say m/yy? I keepy trying field settings then number format and its not working
Date
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
<8/1/2017

An option could be to group years as well. Right-click a cell with one of the months > group > select Years and months. This will put the months in chronological order.

Related

Pro-rated leave calculation

Is there any formula that I can transform to excel language for the following condition:
He joined in on 1st Aug 2019
1 Aug 2019 to July 2020 is his 1 year
on his second year we count from Aug 2020 to July 2021 is his 2nd year.
So for his pro-rated leave, we need to do a manual calculation by breaking apart the months due to different entitlement based on length of services.
Why we calculate like this is becos on 1st year he is entitled to 10 days leave but 2nd year onwards he is entitled to 12 days leave and Max is 16 days leave upon working on the 5th year.
Jan 2021 to July 2021 = 7 months/12*10 =5.83 (Multiple 10 is becos Jan 21 - Jul 21 is his 1st Year)
Aug 2021 to Dec 2021 = 5 months/12*12 =4.99 (Multiple 12 is becos Aug 21 to Dec 21 is his 2nd Year)
Next we will add up 5.83 + 4.99 = 10.82 (Round down to 10.5)
currently, im using this formula to tabulate their leave entitlement based on their joined year.
=IF([#[No. of years Joined]]=0,16,IF([#[No. of years Joined]]<2,16+[#[No. of years Joined]]-0.5,20))
Leave entitlement based on Job grade and length of services
However, this formula doesnt achieve the correct leave entitlement.
Current System
Check out the solution which I have created.
In the image the following are the formulas which I have used
In Cell C7
=DATEDIF(B7,DATE(2022,1,1),"M")
In Cell D7
=(QUOTIENT(C7,12)+1)*12-C7
In Cell E7
=12-D7
In Cell F7
=VLOOKUP(ROUNDDOWN(C7/12,0),$B$1:$C$4,2)
In Cell G7
=VLOOKUP(ROUNDUP(C7/12,0),$B$1:$C$4,2)
In Cell H7
=D7/12*F7+E7/12*G7
I hope this is your requirement.
Of course you can extend this table to include various paygrades (by having another lookup column) and extend it to further years too (by changing the formula in C7).

Cognos report studio filter from Feb data to last closed month

Cognos report studio filter from Feb data to last closed month.
I need to build a report that should show data from Feb to last closed month.
If I run the report in March, it should show the data only for Feb.
If I run the report in Dec, it should show the data from Feb to Nov.
If I run the report in Jan, it should show the data from Last Year Feb to last year Dec.
If I run the report in Feb, it should show the data from Last Year Feb to current year Jan.
Is anyone can help?
#Cognos # CognosBI #CognosDeveloper.
Create a filter expression of [Itemtobefiltered] between [StartDate] and [EndDate]
The [StartDate] query calculation should have an expression of:
if (extract(month,current_date)<=2)
then
(_first_of_month(_add_years(current_date,-1)))
else
(cast(cast(extract(year,current_date),varchar(4))+'-02-01',date))
The [EndDate] query calculation should have an expression of:
_last_of_month(current_date)

Filter dates by month in pivot table that doesn't start with the 1st of every month

Does anyone know how to filter dates by specific dates by month such as Jan 15 to February 15, Feb 15-March 15....etc on pivot table in excel?
My data is January 15 2017 to January 15 2018, so I like to filter it by specific dates but so far it's only letting me do the number of days which is not accurate since feb has only 28 days. thank you!

How to count running months of a specific year?

I'm currently struggling with calculating the running months depending on the year. I have the following table:
Received Month Received Year
Feb 2018
Feb 2018
Mar 2018
... ...
Nov 2018
Nov 2018
Dec 2018
Dec 2018
Jan 2019
Jan 2019
Feb 2019
I was using this formula to count the # of unique months (running months in 1 single cell [C1]);
=SUMPRODUCT(1/(COUNTIF(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month])))
This was working great in 2018, it gave me 11 (Feb - Dec).
I have to add a filter that also checks if the year is 2019. I can't remove 2018 in the table because the operators are still using the 2018 lines. The filter is just here to set a KPI for 2019.
For some reason I can't figure out how to add the year. I tried;
=SUMPRODUCT(1/(COUNTIFS(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month],KAIZEN_Table[Received Year], "2019")))
This is just giving me a 0.
Any suggestions on this? VBA code is also fine.
Edit: After extensive googling I found a working formula, for whoever might be interested in this.
=SUM(IF(FREQUENCY(IF(tbl[Year]=2019,MATCH(tbl[Month],tbl[Month],0)),ROW(tbl[Month])-ROW($L$5)+1),1))
L5 = First row of tbl[Month]
I have my data in A1:B14, the formula I've used is an array one
=SUM(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
however,
=SUMPRODUCT(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
would suffice
To do a particular year, you could do something like this
=SUM(($B$1:$B$14=2019)*(1/COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,B1:B14)))
Another approach is to use a Pivot Table.
On the Create Pivot Table dialog, select to Add this data to the Data Model
If you do this, you will note that one of the options in the Value Field Settings will be Distinct Count
Drag Received Year to the Rows Column; Received Month to the Values column, and select Distinct Count for the Value Field Setting

Finding the difference in minutes or seconds for two timestamps in excel?

I have two columns in a excel containing value like : Mon Dec 01 09:27:04 2014.
Lets say column A and column B and each column has rows containing values in the above format. How can we find the difference between two dates?
Mon Dec 01 09:27:04 2014 - Sun Nov 30 11:08:36 2014 = 25 hrs 51 minutes
Please see this for how to do that..
A more direct answer: you can format the cell
=TEXT(B2-A2,"h:mm")
I suspect the data is text strings for which I suggest:
=VALUE(MID(A1,9,2)&"/"&MID(A1,5,3)&"/"&RIGHT(A1,4))-VALUE(MID(B1,9,2)&"/"&MID(B1,5,3)&"/"&RIGHT(B1,4))+(MID(A1,12,8)-MID(B1,12,8))
However this relies on Excel's ability to interpret the likes of Dec as the month of December which may not be the case for all language versions. If so, I suggest a lookup table and extracting the dates with DATE along these lines:
=DATE(RIGHT(A1,4),VLOOKUP(MID(A1,5,3),Table,2,0),MID(A1,9,2))
However by such calculation the difference of the timestamps given in the question is:
22 hrs 18 minutes 28 seconds
when formatted:
[hh] "hrs" mm "minutes" ss "seconds"

Resources