Forum Discussion
Problem with STDEV
- 10 years ago
I think at this point you go to https://support.powerbi.com and use the Contact Support link to submit a bug.
Hi austinsense and Greg_Deckler
I have the same problem
Fact (Itemkey,DateKey,Demand) Demand is Measure from source.
DimDate (DateKey,MonthNumber)
DimItem(ItemKey,ItemNumber,CompanyKey)
Now i am trying to create standard deviation but the function 'Stdev.P' is not working.
all values are as 0's
So i tried another way by calculating individual steps:
Note: All the calculations are Measures.
CounOfMonth = COUNT(DimDate[MonthNumber])
Mean = CALCULATE([CounOfMonth],ALLSELECTED(DimItem[ItemNumber]),ALLSELECTED('Fact'))
AvgDemand = DIVIDE(CALCULATE(SUM('Fact'[Demand]),ALLSELECTED('Fact'),ALLSELECTED(DimItem[ItemNumber])),[Mean],0)
Demand-AvgDemand = SUM('Fact'[Demand]) - [AvgDemand]
Sqr(Demand-Avg) = [Demand-AvgDemand]^2
Sqr(Demand-Avg)/Mean = DIVIDE([Sqr(Demand-Avg)],[Mean],0)
till here values are coming fine but not totals. and i concern about totals why because i once i remove MonthNumber from the table only one record and one total will which will be the same values.
OR Combining all above formulas into a single Measure is also coming fine, as:
StdDev = DIVIDE((CALCULATE(SUM('Fact'[Demand]),ALLSELECTED(DimItem[ItemNumber])) - DIVIDE ( SUMX (ALLSELECTED('Fact'),'Fact'[Demand]),[Mean]))^2,[Mean])
Once you add all values in Sqr(Demand-Avg)/Mean column
OR
Once you add all values in StdDev column
AND
Try try to do square root of it it is giving me the correct standard deviation as follows:
I filtered on a single item and working on it.
But when i try to complete standard deviation formula by applying SQRT to StdDev:
StdDev = SQRT(DIVIDE((CALCULATE(SUM('Fact'[Demand]),ALLSELECTED(DimItem[ItemNumber])) - DIVIDE ( SUMX (ALLSELECTED('Fact'),'Fact'[Demand]),[Mean]))^2,[Mean]))
OR
by creating another Measure:
SQRT = SQRT(CALCULATE([Sqr(Demand-Avg)/Mean],ALLSELECTED(DimItem[ItemNumber]),ALLSELECTED('Fact')))
The results looks like this
Why my totals are not coming fine?
What did i miss?
Thanks in advance.