function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SeraphSeraph 

N>Change field Month Key (201503 to "March 2015") in object record

Is it possible to change Month Key field value to month year format?

ex.
201503 => March 2015
201401 => January 2014

I need it for REPORTS (x-axis) because 201401 format doesn't look good but I don't know if it can be changed and how to do it?
THX...
Best Answer chosen by Seraph
sandeep sankhlasandeep sankhla
Hi,

Follow the steps:

1. Create one formula field on same object .....
2. Substring it for last 2 digits then you will get 04 or whatever ..
3. check if it is 01 assign jan, if 02 assign feb , if 03 assign march lik ethis chcek for all 12 months and get the string
4. from step 2 you got 2 values one is 2015 and then 2 digits...
5. from step 3 you will get the month name then just + 2015 
6. so finally your formula will return you the date like

if it is 201503 then it will show March 2015

then in reports you use new formula field which is having proper value..

Thanks,
Sandeep

All Answers

sandeep sankhlasandeep sankhla
Hi Seraph,

Yes we can achieve this...you can create one more field which you will update with proper format...you can use substring and check if last 2 digits are 01, 02 and 03 or so on then you can identify the month and then rest will be the year....

You can create one formula field and do these things...
thanks,
Sandeep
SeraphSeraph
@sandeep I haven't tried using formulas  and I read some of the formula functions but I can't find what to use for substring
User-added image
I just wanted to replace those bottom values to Month Year  201503 => March 2015
sandeep sankhlasandeep sankhla
Hi,

Follow the steps:

1. Create one formula field on same object .....
2. Substring it for last 2 digits then you will get 04 or whatever ..
3. check if it is 01 assign jan, if 02 assign feb , if 03 assign march lik ethis chcek for all 12 months and get the string
4. from step 2 you got 2 values one is 2015 and then 2 digits...
5. from step 3 you will get the month name then just + 2015 
6. so finally your formula will return you the date like

if it is 201503 then it will show March 2015

then in reports you use new formula field which is having proper value..

Thanks,
Sandeep
This was selected as the best answer
SeraphSeraph
Thx sandeep for simplifying your previous explanation...what formula return type do I use?
Date,Number, or Text
sandeep sankhlasandeep sankhla
You can use text as this will be text only....
SeraphSeraph
@sandeep..I was able to get the correct result I wanted 201503 => March 2015 with this formula field code I made

CASE(TEXT(MID(Month_Key__c , 5, 2)),
1, "January " + (MID(Month_Key__c , 1, 4)),
2, "February " + (MID(Month_Key__c , 1, 4)),
3, "March " + (MID(Month_Key__c , 1, 4)),
4, "April " + (MID(Month_Key__c , 1, 4)),
5, "May " + (MID(Month_Key__c , 1, 4)),
6, "June " + (MID(Month_Key__c , 1, 4)),
7, "July " + (MID(Month_Key__c , 1, 4)),
8, "August " + (MID(Month_Key__c , 1, 4)),
9, "September " + (MID(Month_Key__c , 1, 4)),
10, "October " + (MID(Month_Key__c , 1, 4)),
11, "November " + (MID(Month_Key__c , 1, 4)),
12, "December " + (MID(Month_Key__c , 1, 4)),
"None")

The problem is it shows wrongly on report since it lists the Months in alphabetical order...zzz
User-added image
sandeep sankhlasandeep sankhla
Hi,

Then if you need to show these with order by years then you split like

201503 => March 2015 instead of these you do ==>2015 March

 
SeraphSeraph
@sandeep I think you misunderstood..I want it sorted in months like its original which was automatically sorted because those were originally numbers.

ex
before: x-axis
201503 - 201504 - 201505

I need it like
March 2015  -  April 2015 - May 2015


 
sandeep sankhlasandeep sankhla
Hi,

You can then concatenate like this 
201503 - --------03-March 2015

then only it will get sort based on the number..

 
SeraphSeraph
I only wish to show it as Month Year...thx so much anyway @sandeep I was able to start learning about formulas because of these..