Can you provide your example a bit more detailed, please?
On which level e.g. MONTHPRODLOCCUST is the KF1 you want to average?
On which level do you want to maintain your KF2 in which you maintain the vaue "x"? Is thhat the same level? Or would you need that on e.g. MONTHLOC or...
Do you plan to change the value for "X" constantly or is that more or less fixed once it's set?
And how do you intend to display it in Excel?
I will not provide you with help for LCode as that is not supposed to be used.
But depending on your requirement you may be able to solve it differently
For example, there was already a post on how to make a quarterly average, for which alone there where minimum two possibilities posted at the time
Plus, if you just want flexible to see an average but dont need that in the grid , you can just mark those cells in excel and see the average on the bottom right corner anyhow
Or you build an EPM key figure if you just want to see one value and not a rolling value by adding a column in which you make the average depending on any other cell you provide somewere above your planning grid...
You see there may be more solutions to your problem than just LCode. WOuld be good if you provide a mockup-excel how it should look like
Yours
Irmi