Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jacek27031
Contributor III
Contributor III

Calculating average measure

How to calculate and create AVG W4 average measure as INV for a given week divided into sum of SO for the last 4 weeks?

Calculated measure - [AVG W4]

Measure 1 - [SO]

Measure 2 - [INV]

Dimension - [Week Flag]

jacek27031_0-1631797980826.png

Excel example.

jacek27031_1-1631798039429.png

 

Thanks for any help.

1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

Try this.  Replace sum([SO]) with your actual expression for [SO]

 [INV]  /  Rangesavg(before(sum([SO]), 0,4))

 

If you want to ignore filter selection on Week Flag if user makes a selection in this field, you can do this:

 [INV]  /  (Rangesavg(before(sum({<[Week Flag]=>} [SO]), 0,4)) * count(distinct [Week Flag]) )

//where multiplying by count distinct week flag will just zero out the non selected values but keep the correct calculation for your rangeavg value.

View solution in original post

8 Replies
stevejoyce
Specialist II
Specialist II

Try this.  Replace sum([SO]) with your actual expression for [SO]

 [INV]  /  Rangesavg(before(sum([SO]), 0,4))

 

If you want to ignore filter selection on Week Flag if user makes a selection in this field, you can do this:

 [INV]  /  (Rangesavg(before(sum({<[Week Flag]=>} [SO]), 0,4)) * count(distinct [Week Flag]) )

//where multiplying by count distinct week flag will just zero out the non selected values but keep the correct calculation for your rangeavg value.

jacek27031
Contributor III
Contributor III
Author

hmm...

jacek27031_0-1631802107446.png

 

jacek27031
Contributor III
Contributor III
Author

jacek27031_1-1631802238778.png

 

stevejoyce
Specialist II
Specialist II

Sorry looks like you fixed the typo in rangeavg calculation.  are you still having an issue?

 

Note, i don't know if [SO] is your field name or the name/label of  your measure.  Please update sum([SO]) to the correct formula.

 

jacek27031
Contributor III
Contributor III
Author

sorry, my bad, wrong names, should be

INV = [# On Hand Inventory Quantity]

SO = [# Sales Out Quantity]

[# On Hand Inventory Quantity] / Rangeavg(before(sum([# Sales Out Quantity]), 0,4))

jacek27031_0-1631802673436.png

however seems it's not working ;/

jacek27031_1-1631802782594.png

 

stevejoyce
Specialist II
Specialist II

Calculation should be fine other then your personal fields/calculations.  I'm guessing your numerator should be sum([# On Hand Inventory Quantity]).

jacek27031
Contributor III
Contributor III
Author

Got it! thanks a million, @stevejoyce!

Sum([# On Hand Inventory Quantity]) / Rangeavg(before(sum([# Sales Out Quantity]), 0,4))

stevejoyce
Specialist II
Specialist II

Great!  Please mark correct solution.