'Power bi and excel formula shows different results

I have the following two tables in excel. Table 1 contains the date, closing share price and log.

enter image description here

In the second table, i have the date and the number of years i will need to consider from table 1 (Log column) for calculating the volatility. I have used the following formula to calculate volatility in table 2.

=STDEV.S(IF(('Table 1'!$A$3:$A$10000>=(EDATE('Table 2'!$A3,-('Table 2'!$B312)))('Table 1'!$A$3:$A$10000<='Table 2'!$A3)),'Table 1'!$C$3:$C$10000,""))*SQRT(252)

enter image description here

When i'm replicating the formula in power bi. I'm getting different result in power bi. In power Bi, the std deviation measure should be reference to a column and not as an argument and when i'm splitting the if statement and the std deviation and SQRT formula. it is giving me a different result as shown below.

enter image description here

enter image description here

I have used the followings measures in power bi

If statement = IF((RELATED('Historical share price'[Date])>=(EDATE('Table'[Date],-('Table'[Number of years to calculate]12)))(RELATED('Historical share price'[Date])<='Table'[Date])),RELATED('Historical share price'[Log]),BLANK())

STD = STDEV.S('Table'[If statement])*SQRT(252)

Not sure where i'm going wrong. Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source