0

I am fairly new to Power BI and was hoping to solve my total (multiplication problem).

I have running inventory table for supplies ordered. I need to have a breakdown of the cost of those supplies based on the last item ordered(prices constantly change). I have two measures, one for the latest cost, and the second for the latest units used.

Latest Unit/Cost =
VAR maxdate =
    MAX ( InventoryJ[Date Ordered] )
RETURN
    CALCULATE ( SUM ( InventoryJ[Cost/Unit] ), InventoryJ[Date Ordered] = maxdate )

and

Latest UnitsUsed =
VAR maxdate =
    MAX ( InventoryJ[Date Ordered] )
RETURN
    CALCULATE ( SUM ( InventoryJ[Unit Used] ), InventoryJ[Date Ordered] = maxdate )

In my matrix they work great, even though the total is incorrect in the table.

Matrix table

Now I am stuck on multiplying these two measures together for the latest units used and the latest cost per unit and then summarizing the total for the values.

Best Regards

Angelo Canepa
  • 1,701
  • 2
  • 13
  • 21
Atta
  • 1
  • 1
  • 1

1 Answers1

0

Assuming your table looks like this

Table

Items Unit Cost Unit Used Date
Item 1 4.25 16 03 November 2021
Item 1 3.44 20 03 December 2021
Item 1 3.93 48 13 March 2021
Item 1 7.57 32 14 March 2021
Item 1 2.45 33 15 March 2021
Item 1 7.32 34 16 March 2021
Item 1 3.34 33 17 March 2021
Item 1 9.17 26 18 March 2021
Item 1 9.59 25 19 March 2021
Item2 4.1 27 03 November 2021
Item2 1.74 47 03 December 2021
Item2 8.08 19 13 March 2021
Item2 7.52 13 14 March 2021
Item2 6.7 49 15 March 2021
Item2 4.24 13 16 March 2021
Item2 0.95 40 17 March 2021
Item2 0.37 19 18 March 2021
Item2 9.77 38 19 March 2021

Calculation

You can use SUMX and LASTDATE to get the last Unit Cost multiplied by Unit Used.

Cost =
CALCULATE (
    SUMX ( 'Table', [Unit Cost] * [Unit Used] ),
    LASTDATE ( 'Table'[Date] )
)

Output

enter image description here

Angelo Canepa
  • 1,701
  • 2
  • 13
  • 21