DAX question weighted average across granularities

jake32008

New Member
Joined
Apr 10, 2015
Messages
27
Forgive my ignorance as I'm a bit of a noob but I am attempting to calculate the following two measures in PowerPivot:


FILL RATE @ PO LEVEL = [QTY RECEIVED]/[QTY ORDERED]
For example, in the table below, the [QTY RECEIVED] would be the sum of (10,0,125,15) and [QTY ORDERED] would be 150 (not the sum of {150,150,150,150})

DELIVERY COMPLIANCE RATE @ PO LEVEL = AVERAGE OF [DELIVERY COMPLIANCE] WEIGHTED BY QTY RECEIVED OUT OF TOTAL QTY ORDERED WHERE [DELIVERY COMPLIANCE] is a calculated column = IF([RECEIPT DATE] <= [REQUIRED DATE],1,0)

For example, again in the table below, [PO NO] 0027380 ordered 150 of [Item Code] 111248. 10k were received on [RECEIPT NO] 033243, 0 on [RECEIPT NO] 034122, 125 on [RECEIPT NO] 034180, 15 on [RECEIPT NO] 034223. The result I am looking for would be 6.7% delivery compliance (1*10,1*0,0*125,0*15) like an array formula.

I would also like it to roll up correctly using this same line of thinking to the item and vendor level.

Thank you in advance for your assistance in helping me better understand DAX!

VENDOR NAMEITEM CODEPO NORECEIPT NOREQUIRED DATERECEIPT DATEDELIVERY COMPLIANCE RATEQTY ORDEREDQTY RECEIVED
BCS11124800273800332432/13/201512/18/2014100%15010
BCS11124800273800341222/13/20152/13/2015100%1500
BCS11124800273800341802/13/20152/18/20150%150125
BCS11124800273800342232/13/20152/23/20150%15015

<tbody>
</tbody>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
One option is to make the following measures

QTYORD:=MAX(Sheet1[QTY ORDERED])
QTYRECEIVED:=SUM(Sheet1[QTY RECEIVED])
FILL RATE:=DIVIDE([QTYRECEIVED],[QTYORD])

DELIVERYCOMPLIANCEQTY:=CALCULATE(SUM(Sheet1[QTY RECEIVED]),FILTER(Sheet1,Sheet1[RECEIPT DATE] <= Sheet1[REQUIRED DATE]))
DELIVERYCOMPLIANCERATE:=DIVIDE([DELIVERYCOMPLIANCEQTY],[QTYORD])
 
Upvote 0
Kazlik! You are awesome my friend!

At that level it's gotten me exactly what I needed, but at the item level it adds up the QTYRECEIVED and returns 140%.

I just tried using IF(HASONEVALUE( to back it up to ITEM then VENDOR level to no avail. Any tips?

VENDORITEM CODEPO NORECEIPT NOQTY ORDQTYRECEIVEDFILL RATEDELIVERYCOMPLIANCEQTYDELIVERYCOMPLIANCERATE
BCS1112480027380033243150106.7%106.7%
03418015012583.3%00%
0342231501510%00%
111248 TOTAL150210140%106.7
BCS TOTAL3852706702.9%1845500479.4%

<tbody>
</tbody>


Thanks again!
 
Last edited:
Upvote 0
I think if you add a new measure MAXQTYORD:=MAX(Sheet1[QTY ORDERED]) and then update the QTYORD:=SUMX(DISTINCT(Sheet1[PO NO]),[MAXQTYORD]) like this it should work.
 
Upvote 0
THANKS AGAIN!! I had to use the old noggin' a bit but I expanded it to QTYORD:=SUMX(DISTINCT(Sheet1[Item Code]),SUMX(DISTINCT(Sheet1[PO NO]),[MAXQTYORD]) ) and it now rolls up correctly all the way!

Jake
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,390
Members
449,445
Latest member
JJFabEngineering

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