Forum Discussion
JoyceW
Helper II
7 years agoCalculating average inventory by adding the begin amount and the end amount and then dividing by 2
Hi, I have Power BI linked to our Exact database. I have the following table: itemnumber, date, amount, value. 1-1 = 10 2-1 = 20 3-1 = 40 Average should be: (40+10 )/2 = 25 I have ...
Anonymous
7 years agoNot applicable
Hi JoyceW ,
Is there any index field in your table? If this is a case, you can write formula to use index to find out correspond begin value and end value, then use them to get average.
AVG Measure =
VAR _start =
MINX ( ALLSELECTED ( Table[index] ), [index] )
VAR _end =
MAXX ( ALLSELECTED ( Table[index] ), [index] )
RETURN
DIVIDE (
LOOKUPVALUE ( Table[Amount], Table[index], _start )
+ LOOKUPVALUE ( Table[Amount], Table[index], _end ),
2,
BLANK ()
)
Otherwise you need to add index column first.(power bi data model not contains row/column index to find out first or last row value)
Regards,
Xiaoxin Sheng
MAAbdullah_47
Helper V
5 years agoHi Anonymous The Index is it related to the Dates Table ? Kindly please explain by an example.