I'm OK with using measures to assign which bin of a histogram an item should go but I'm having an awful time figuring out how to do it when the column value itself is what determines a bin.
Assume there is a Histogram table with 3 columns of bin label, max val, and min val.
My data table has a column of Days on Hand (DoH) for each item in a storeroom. If an item has a DoH of 12 then I want it to go into bin label 12 of the histogram.
But of course the code fails because the Storeroom[DoH] field I'm bumping against the histogram bin levels is not SUM or AVERAGE etc. I've tried COUNTROWS(VALUES(DoH)), FIRSTNONBLANK(VALUES(DoH)) and other constructs, but the first one simply groups the DoH by how many different values of DoH I have. (e.g. if my Storeroom has an item with DoH of 4 at the box quantity, 7 at the roll, and 11 at the case then it places the item in the "3" bin because there are 3 separate DoH values. I'd like one value in the 4 bin, one in 7, and one in the 11 bin.)
It's probably a simple formula but I'm not getting it!
Assume there is a Histogram table with 3 columns of bin label, max val, and min val.
My data table has a column of Days on Hand (DoH) for each item in a storeroom. If an item has a DoH of 12 then I want it to go into bin label 12 of the histogram.
Code:
Days on Hand:=CALCULATE (
[Storeroom Item Total],
FILTER (
VALUES ( 'Storeroom'[Unique Item]),
COUNTROWS (
FILTER (
Histogram,
Storeroom[DoH] >= Histogram[MinVal]
&& Storeroom[DoH] < Histogram[MaxVal]
)
)
)
)
But of course the code fails because the Storeroom[DoH] field I'm bumping against the histogram bin levels is not SUM or AVERAGE etc. I've tried COUNTROWS(VALUES(DoH)), FIRSTNONBLANK(VALUES(DoH)) and other constructs, but the first one simply groups the DoH by how many different values of DoH I have. (e.g. if my Storeroom has an item with DoH of 4 at the box quantity, 7 at the roll, and 11 at the case then it places the item in the "3" bin because there are 3 separate DoH values. I'd like one value in the 4 bin, one in 7, and one in the 11 bin.)
It's probably a simple formula but I'm not getting it!