Forum Discussion
maqsud
6 years agoHelper III
Assign measure value in Calculated Column
I want to assign below measure value as Calculated column While putting the formula of Measure in the Calculated column. I am getting a Blank column. A_B_ =
VAR Correlation_Table =
FILT...
- 6 years ago
Can you upload the file? Also I think you can rewrite the code like this:
A_B_ = VAR Correlation_Table = FILTER ( ADDCOLUMNS ( VALUES ( Demo_NumericalData[Access code] ), "Value_X", CALCULATE ( SUM ( Demo_NumericalData[A] ) ), "Value_Y", CALCULATE ( SUM ( Demo_NumericalData[B] ) ) ), [Value_X] > 0 && [Value_Y] > 0 ) VAR Count_Items = COUNTROWS ( Correlation_Table ) VAR Sum_X = SUMX ( Correlation_Table, [Value_X] ) VAR Sum_X2 = Sum_X ^ 2 VAR Sum_Y = SUMX ( Correlation_Table, [Value_Y] ) VAR Sum_Y2 = Sum_Y ^ 2 VAR Sum_XY = SUMX ( Correlation_Table, [Value_X] * [Value_Y] ) VAR Pearson_Numerator = Count_Items * Sum_XY - Sum_XY VAR Pearson_Denominator_X = Count_Items * Sum_X2 - Sum_X2 VAR Pearson_Denominator_Y = Count_Items * Sum_Y2 - Sum_Y2 VAR Pearson_Denominator = SQRT ( Pearson_Denominator_X * Pearson_Denominator_Y ) RETURN DIVIDE ( Pearson_Numerator, Pearson_Denominator )
AntrikshSharma
6 years agoCommunity Champion
Can you upload the file? Also I think you can rewrite the code like this:
A_B_ =
VAR Correlation_Table =
FILTER (
ADDCOLUMNS (
VALUES ( Demo_NumericalData[Access code] ),
"Value_X", CALCULATE ( SUM ( Demo_NumericalData[A] ) ),
"Value_Y", CALCULATE ( SUM ( Demo_NumericalData[B] ) )
),
[Value_X] > 0
&& [Value_Y] > 0
)
VAR Count_Items =
COUNTROWS ( Correlation_Table )
VAR Sum_X =
SUMX ( Correlation_Table, [Value_X] )
VAR Sum_X2 = Sum_X ^ 2
VAR Sum_Y =
SUMX ( Correlation_Table, [Value_Y] )
VAR Sum_Y2 = Sum_Y ^ 2
VAR Sum_XY =
SUMX ( Correlation_Table, [Value_X] * [Value_Y] )
VAR Pearson_Numerator = Count_Items * Sum_XY - Sum_XY
VAR Pearson_Denominator_X = Count_Items * Sum_X2 - Sum_X2
VAR Pearson_Denominator_Y = Count_Items * Sum_Y2 - Sum_Y2
VAR Pearson_Denominator =
SQRT ( Pearson_Denominator_X * Pearson_Denominator_Y )
RETURN
DIVIDE ( Pearson_Numerator, Pearson_Denominator )- maqsud6 years agoHelper III
AntrikshSharma, This is also giving me Blank Column.
- AntrikshSharma6 years agoCommunity ChampionYes, the behavior is same as the original measure I just made it less verbose, since a measure is being called in a row context created by the calculated column there is a context transition happening and without looking at the data it is impossible to tell why your measure returns blank.