Forum Discussion
Dax
Your goal is to compare the covariance of each individual month with the total covariance across all months. The formula you have provided seems to be on the right track but requires some adjustments to achieve the desired outcome.
Let's break down the steps to make the necessary adjustments:
- Calculate the covariance for each individual month.
- Calculate the total covariance across all months.
- Divide the individual month's covariance by the total covariance to get the proportion.
Here's a revised version of your DAX measure:
CovarianceProportion =
VAR N =
COUNTROWS (
CALCULATETABLE (
VALUES ( 'Custom Calendar Table'[Month] ),
ALLSELECTED ( 'Custom Calendar Table'[Month] )
)
)
VAR CurrentAvg =
CALCULATE (
AVERAGEX ( VALUES ( 'Custom Calendar Table'[Month] ), [SelectedMeasureType] ),
ALLSELECTED ( 'Custom Calendar Table'[Month] )
)
VAR PreviousAvg =
CALCULATE (
AVERAGEX ( VALUES ( 'Custom Calendar Table'[Month] ), [Previous] ),
ALLSELECTED ( 'Custom Calendar Table'[Month] )
)
VAR Individual_Month_Covariance =
DIVIDE (
([SelectedMeasureType] - CurrentAvg) * ([Previous] - PreviousAvg),
N
)
VAR CovTable =
SUMMARIZE (
'Custom Calendar Table',
'Custom Calendar Table'[Month],
"@cov", Individual_Month_Covariance
)
VAR Total_of_AllMonths_Covariance =
CALCULATE (
SUMX ( CovTable, [@cov] ),
ALLSELECTED ( 'Custom Calendar Table'[Month] )
)
RETURN
DIVIDE ( Individual_Month_Covariance, Total_of_AllMonths_Covariance, 0 )
Make sure to replace [SelectedMeasureType] and [Previous] with the appropriate measures or columns you are using for your calculation. Also, ensure that your 'Custom Calendar Table' has the necessary data for the months you are analyzing.
This revised measure should help you obtain the proportion of each individual month's covariance relative to the total covariance across all months.
Hi Thanks for replying,
I have done this earlier as you suggested fof Total Coverience
VAR Total_of_AllMonths_Covariance =
CALCULATE (
SUMX ( CovTable, [@cov] ),
ALLSELECTED ( 'Custom Calendar Table'[Month] )
)
But it is not working. I cross checked, Its giving the same value as Indivisual Coverience when placed it in a table visual months as row value, where as it should be same total covarience value againts all months.