Forum Discussion
Measure returning unexpected value
- 5 years ago
Hi Quite_lost ,
Based on your description, I checked your example pbix and found the problem.
The reason is that you turn off the interaction between Movement Type slicer and Days "in stock".
Correspondingly, you need to clear the filter of Movement Type in the calculation.
Average Sales by Month "in stock" = var t = [Total Quantity] var m = CALCULATE([Months "in stock"],ALL('Stock History'[Movement Type])) return DIVIDE(t,m)Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Quite_lost , can you share formulas of three involved
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
- Quite_lost5 years agoFrequent Visitor
Here is the pbix file.
Here are the formulas I'm using:
#Total Quantity = SUM('Stock History'[Quantity]) *-1 #Cumulative Total = CALCULATE( [Total Quantity], FILTER( ALL( Dates[Date] ), Dates[Date] <= MAX( Dates[Date] ) ) ) #Days "in stock" = COUNTROWS(FILTER(ADDCOLUMNS(CROSSJOIN( VALUES( Dates[Date] ), VALUES('Stock History'[Product]) ), "Inventory Levels", [Cumulative Total] ), [Inventory Levels] <> 0 && NOT( ISBLANK( [Inventory Levels] ) ) ) )-1 #Days "zero stock" = COUNTROWS( FILTER( ADDCOLUMNS( CROSSJOIN( VALUES( Dates[Date] ), VALUES('Stock History'[Product]) ), "Inventory Levels", [Cumulative Total] ), [Inventory Levels] = 0 && NOT( ISBLANK( [Inventory Levels] ) ) ) #Months "in stock" = [Days "in stock"] / 30.41666 #Average Sales by Month "in stock" = [Total Quantity] / [Months "in stock"]- V-lianl-msft5 years agoCommunity Support
Hi Quite_lost ,
Based on your description, I checked your example pbix and found the problem.
The reason is that you turn off the interaction between Movement Type slicer and Days "in stock".
Correspondingly, you need to clear the filter of Movement Type in the calculation.
Average Sales by Month "in stock" = var t = [Total Quantity] var m = CALCULATE([Months "in stock"],ALL('Stock History'[Movement Type])) return DIVIDE(t,m)Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Quite_lost5 years agoFrequent Visitor
Wow, that really worked!
Thank you very much!
I need to learn a lot more about filter and contexts.