Forum Discussion
Standard Deviation yields NaN error
Good Afternoon All & Greg_Deckler
Following up on my previous thread wherein I used the following formula to calculate Standard Deviation:
StdDev_EquipID =
VAR __table = SUMMARIZE(GeneralStatistics,[Date],"__EquipID",[EquipmentIDRatio])
RETURN STDEVX.P(__table,[__EquipID])
There are several data points where my denominator (TotalVisits) is a zero and hence believe this is what is giving me an "NaN" error in my STDDEV calculation.
Would appreciate advice on how to correct the above formula to ignore the line records where TotalVisits = 0.
Thanks in advance and best regards,
try
StdDev_EquipID = VAR __table = SUMMARIZE(FILTER(GeneralStatistics, GeneralStatistics[TotalVisits] <> 0),[Date],"__EquipID",[EquipmentIDRatio]) RETURN STDEVX.P(__table,[__EquipID])
6 Replies
- az38Community Champion
try
StdDev_EquipID = VAR __table = SUMMARIZE(FILTER(GeneralStatistics, GeneralStatistics[TotalVisits] <> 0),[Date],"__EquipID",[EquipmentIDRatio]) RETURN STDEVX.P(__table,[__EquipID]) - edhansCommunity Champion
Can you not just filter them out like this?
VAR __table = SUMMARIZE( FILTER( GeneralStatistics, TotalVisits <> 0 ), [Date], "__EquipID", [EquipmentIDRatio] ) RETURN STDEVX.P( __table, [__EquipID] ) - AlexisOlsonSuper User
The formula is correct. Standard deviation is undefined for a zero denominator.
If you want to show something else instead of NaN you can write that rule into your measure:
StdDev_EquipID = VAR __table = SUMMARIZE ( GeneralStatistics, [Date], "__EquipID", [EquipmentIDRatio] ) VAR SD = STDEVX.P ( __table, [__EquipID] ) RETURN IF ( ISERROR ( SD ), BLANK (), SD )