The term simple should probably be avoided when speaking of SSAS. For those of you wondering what SSAS is, it's short for SQL Server Analysis Services. Now if your wondering what's that, this blog post is probably not for you. However if you are involved in database reporting in any shape or form, I encourage you to take some time to familiarize yourself with it, it's very powerful when applied.
Recently, when trying to work on a relatively new cube for my company, I had some difficulty finding a clear explanation on how to accomplish the task of generating an Average value based off my fact table. In my efforts to find the answer I saw that, like many other things, there are many ways to skin the cat. While searching I came across a lot of references to calculated measures, but no great tutorials on how to implement it. Hopefully I can remedy that by providing a somewhat decent tutorial on creating a basic calculated measure.
In my scenario, my fact table has a "Seconds Elapsed" column that represents the amount of time spent on each line item. My goal is to allow all my dimensions, including time, sum and average the "Seconds Elapsed". In some cases you may want to avoid including a time dimension in your measure, which is a semi-additive, and not covered in this post. So conveniently, were going to let every dimension have it's dirty little way with our measures.
So, we have our measure for "Seconds Elapsed", and it's set to sum. This measure includes zero values, and values greater then zero, all of an Integer type. You can see an example of the data in question from this picture taken from an "Explore Data" view of our fact table.
So ignoring SSAS in general, what's the basic formula to find the average value of something? Sum / Count. Essentially an aggregate divded by an aggregate. To find the average time elapsed we need to take the Sum of "Seconds Elapsed" in scope and divide it by the in scope Count. Scope is easy in our example since it has no limitations no matter the dimension. Scope could potentailly be a bit more difficult to deal with if we were going to use our average as a Semi-additive.
So, lets build what we need for our calculated measure, we already have our Sum measure in "Seconds Elapsed", but next we need a count measure, as a generic count of our fact table would not be suitable. The reason for this is some of our "Seconds Elapsed" fields have 0 values. If we include these zero values in our Count, it'll skew our average. So we need to create a measure that gives us a count of only the "Seconds Elapsed" with a value greater then zero. To do this we create a named calculation by right clicking our fact table in the data source view and choose new named calculation. This brings up a form allowing us to enter our calculation.

As you can see we use basic T-SQL here to evaluate our "Seconds Elapsed" column and result in a 0 or 1. This will give us a new measure that we can Sum as our divsor. Now no matter what dimension we apply, we'll have an accurate count of how many rows to include as our divisor in our average calculation.

As you can see in the picture above, where we have a "Seconds Elapsed" value greater then zero, the "TimeAverageDivisor" column has a 1, and all other values are 0, thereby giving us our accurate count. We will now include "TimeAverageDivisor" as a measure, by going to our cube structure, and adding a new measure, then choosing our named calculation, setting the aggregate to "Sum".
Finally, we've got all our building blocks, so now we need to create our calculated Measure. To do this, we go to our cube and click on the calculations tab.

The small green arrow above I've so amazingly crafted with MSPaint, is pointing out the "New Calculated Measure" button. Cllicking on this will bring the handy dandy window that lets you input your basic information about this new measure your creating, and the associated formula. Best advice at this point is, to use drag-and-drop techniques to write your formula for you. On the left we see our dimensions and measures. We will drag out our "Seconds Elapsed" sum measure, enter the standard division symbol "/" and then drag out our "AverageTimeDivisor" we built earlier.

The query is a very basic MDX Expression, named "AverageTimeSpent", and will be automatically made available as a new measure in any of our analysis done. That's the end, build and deploy your solution, and you should now have an "AverageTimeSpent" measure. Feel free to hit me up with any questions to fill in any holes I may of missed.