Supply frequency measure...

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,717
Hi Team,

Looking for some help to do the following...

Data as follows:

WeekProductSupply
1Apple0
2Apple0
3Apple0
4Apple5
5Apple0
6Apple0
7Apple10
8Apple0
9Apple10
10Apple0
11Apple0
12Apple0
13Apple0
14Apple0
15Apple5
16Apple0
17Apple0
18Apple5
19Apple0
20Apple10
1Banana20
2Banana0
3Banana20
4Banana20
5Banana0
6Banana30
7Banana0
8Banana0
9Banana0
10Banana20
11Banana20
12Banana0
13Banana0
14Banana0
15Banana0
16Banana0
17Banana0
18Banana0
19Banana0
20Banana0

<tbody>
</tbody>

I want a DAX measure to return the following results:

ProductSupply Frequency
Apple3.20
Banana2.00

<tbody>
</tbody>

Which was computed using standard Excel functions as follows:

Code:
=COUNTIF(INDEX(C$2:C$41,MATCH(1,((B$2:B$41=E2)*(C$2:C$41>0)),0)+1):INDEX(C$2:C$41,MATCH(2,1/((B$2:B$41=E2)*(C$2:C$41>0)))),">=0")/COUNTIF(INDEX(C$2:C$41,MATCH(1,((B$2:B$41=E2)*(C$2:C$41>0)),0)+1):INDEX(C$2:C$41,MATCH(2,1/((B$2:B$41=E2)*(C$2:C$41>0)))),">0")

Logic used:

Per product, establish the range of interest by determining the first and last weeks where supply occurred (note that the first week is always moved on by 1 to 'correct' the range for calculation purposes). In the case of 'Apple', a count of 16 is returned (weeks 5 through to 20). Now, divided this number by the number of times supply has occurred over this same time period. For Apple, 5 is returned (supply occurred in weeks 7, 9, 15, 18 and 20). Finally, divide 16 by 5 to get the desired result: 3.2.

Hope this is clear and someone can assist.

Cheers,

Matty
 
In some ways they are like excel formulas, but CALCULATE is a notable exception.

Maybe think about CALCULATE with two parameters as:

Code:
CALCULATE (
     {calculate whatever is written here},
     {but imagine you are in a world as defined here}
)
Therefore you need to know the second parameter before you can work out what the first returns.

That's a good way of thinking about things. :cool:

Cheers!

Matty
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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