cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JoyceW
Frequent Visitor

Calculating 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 to use this to calculate the inventory turnover. 

 

When I use average it does 10+20+40 and divides it by 3. 

 

Also, I would like to do this per month, quarterly year and year. 

 

Any suggestions are greatly appreciated. 

3 REPLIES 3
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft  The Index is it related to the Dates Table ? Kindly please explain by an example. 

Hi @v-shex-msft , thanks for your reply.

 

i'm not sure how an index field would work, since the table contains many dates and many item numbers. So it should pick the first date and the last date of an item number and then divide it. It would even be better if I could show the first and last date in a month, in a quarter and in a year. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.