Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 in Table1 and what I´m getting is Covar2. I checked the sum of colum .Covar2 in excel and its equal to the expected value Covar. The context is ruled by the date slicer and Asset Filter.
Any help would be fully appreciated.
Solved! Go to Solution.
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
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 I'm not understanding your use of SUMX here. Result being a variable will always be the same value so I do not believe SUMX(Base,Result) should be any different than just Result. Perhaps you meant to create a table variable and use ADDCOLUMS with the Result calculation as a column in the table and then SUMX across it?
@Greg_Deckler thanks for your answer. I just wanted to add all the values of Result. When I just called Var Result it didnt show the expected value ( -0.0000795701 ). I´m missing the table variable. Just fyi the SUMX(Base, Result) and just Result returned diferent values. I can share the pbix if you like. Thanks again.
@Fcoatis PBIX would definitely help.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 133 | |
| 88 | |
| 85 | |
| 68 | |
| 64 |