Calculating Average

SimonNU

Board Regular
Joined
Jul 11, 2013
Messages
140
I have three tables: a fact table, a look up table, and a custom date table.

The following formula works correctly when a user selects one period using a slicer from the custom date table, but in reality is should average by the amount of periods selected. How would I do this?

Code:
Metric :=CALCULATE (
    SUM ( 'FCT_TABLE'[AMOUNT] ),
    'DIM_TABLE'[DESCRIPTION] = "Full-time equivalent"
)
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Typically i do something like AmtPerDay := DIVIDE([TotalMetric], COUNTROWS(Calendar)).

Depending on your scenario, dividing by DISTINCTCOUNT(Calendar[PeriodId]) could work?
 
Upvote 0
Thanks Scott!

I don't know why but I was going down a much more difficult route to solve such a simple problem.
 
Upvote 0
I'm encountering a problem with the above formula.

Say for example my data granularity is by period (it's actually weekly, but this is a clearer example). If I slice by just the Year dimension then the results are incorrect because it's dividing by 12 when infact I only have 10 periods of fact data.

The only solution is to create a period slicer and highlight up to period 10.

Basically, is there a way to prevent it from dividing by future dates that don't exist in my fact table?

My formulas are:
Code:
FTE:=DIVIDE(SUM('Timekeeper Filters'[fct_FTE]),COUNTROWS('Time Filters'))

Code:
FTE YTD:=CALCULATE (
    [FTE],
    FILTER (
        ALL ('Time Filters'),
                        'Time Filters'[YYYY] = MAX ( 'Time Filters'[YYYY] ) &&
        'Time Filters'[YYYYPPW] <= MAX ('Time Filters'[YYYYPPW] )
    )
)
 
Upvote 0
Ya, its easier if you have a trimmed calendar table (so the last date in calendar, matches the last day in sales or whatever). Probably easiest to just create a calc column on your calendar table IsFuture ... =Calendar[DateKey] > MAX(Facts[SalesDate]) sorta thing... then you can easily filter out IsFuture?
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,124,999
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top