Forum Discussion
Fcoatis
Post Patron
5 years agoHard time figuring out context
Hello all, Hard time to get the result expected. Every variable has been checked but the problem seem to be the context of "Base" in SUMX: The result expected is the value of Covar...
- 5 years ago
Here is what I ended up.
.Covar = VAR Tabela = FILTER( SELECTCOLUMNS( ALLSELECTED(Base[Date]), "LnAsset", [.ln], "LnIBOV", CALCULATE([.ln],Base[Asset]="IBOV") ), AND ( NOT( ISBLANK( [LnAsset])), NOT ( ISBLANK( [LnIBOV] )) ) ) VAR Denom = COUNTROWS(Tabela)-1 VAR Res = SUMX(Tabela, ([LnAsset]-AVERAGEX(Tabela,[LnAsset]))*([LnIBOV]-AVERAGEX(Tabela,[LnIBOV]))/Denom) RETURN Res
Fcoatis
Post Patron
5 years agoHere is what I ended up.
.Covar =
VAR Tabela =
FILTER(
SELECTCOLUMNS(
ALLSELECTED(Base[Date]),
"LnAsset", [.ln],
"LnIBOV", CALCULATE([.ln],Base[Asset]="IBOV")
),
AND (
NOT( ISBLANK( [LnAsset])),
NOT ( ISBLANK( [LnIBOV] ))
)
)
VAR Denom = COUNTROWS(Tabela)-1
VAR Res = SUMX(Tabela, ([LnAsset]-AVERAGEX(Tabela,[LnAsset]))*([LnIBOV]-AVERAGEX(Tabela,[LnIBOV]))/Denom)
RETURN
Res