Forum Discussion
Sperling
3 years agoAdvocate II
Measure help
Hi, I'm having issues with an out of stock measure. Currently I have an qty. available to sell measure that is made up of two other measures. One is an qty. in stock measure - shows how much...
- 3 years ago
In trying to debug it by splitting it more up, it turned out to work.
Never tried a measure not working by using VAR.
So in my solution I just divided the DAX presented into 2 individual measures:Out of Stock status =VAR QtyAtS =SUMX(DISTINCT(DimItem[Item Number]),[Quantity available to Sell])RETURNIF(CALCULATE(QtyAtS) <= 0,1,0)Out of Stock count =COUNTROWS(FILTER(DISTINCT(DimItem[Item Number]),[Out of Stock status] = 1))
I then divided the Out of Stock count measure with a distinct count of Item Numbers and it works - a bit confused but at least it works.
Sperling
3 years agoAdvocate II
Appreciate the input, but since items exist in multiple companies, the sum of the calculated column is more than 1 if the stock status is out of stock in several. So if it for example is out of stock in 6 companies, the sum will be 6 rather than 1.
Sperling
3 years agoAdvocate II
In trying to debug it by splitting it more up, it turned out to work.
Never tried a measure not working by using VAR.
So in my solution I just divided the DAX presented into 2 individual measures:
Out of Stock status =
VAR QtyAtS =
SUMX(
DISTINCT(DimItem[Item Number]),
[Quantity available to Sell]
)
RETURN
IF(
CALCULATE(
QtyAtS
) <= 0,
1,
0
)
Out of Stock count =
COUNTROWS(
FILTER(
DISTINCT(
DimItem[Item Number]
),
[Out of Stock status] = 1
)
)
I then divided the Out of Stock count measure with a distinct count of Item Numbers and it works - a bit confused but at least it works.
I then divided the Out of Stock count measure with a distinct count of Item Numbers and it works - a bit confused but at least it works.