Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kenj
Frequent Visitor

dax

Hi, I want to compare month wise covarience with the total covarience, messure is as below. It is not working

covarience =

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_Covarience=DIVIDE(
                        ([SelectedMeasureType]-CurrentAvg)*([Previous]-PreviousAvg),
                        N
                        )
VAR CovTab=SUMMARIZE('Custom Calendar Table',
                   
                    'Custom Calendar Table'[Month],
                   
                    "@cov",Individual_Month_Covarience)

VAR Total_of_AllMonths_Covariance=CALCULATE(SUMX(CovTab,[@cov]))
// how to calclate sum of all Indivisual month covariance

RETURN Individual_Month_Covarience/Total_of_AllMonths_Covariance
//  Divide(Individual_Month_Covarience,Total_of_AllMonths_Covariance) to know what portion of the total
// its returnig all 1s when displayed in table with months as row
2 REPLIES 2
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

kenj
Frequent Visitor

Measures are as below

Total All Months covariance =

VAR N=COUNTROWS(CALCULATETABLE(VALUES('Custom Calendar Table'[Month]),ALLSELECTED('Custom Calendar Table')))

VAR CurrentAvg=CALCULATE(
                    AVERAGEX(
                    VALUES('Custom Calendar Table'[Month]),
                    [SelectedMeasureType]
                    ),ALLSELECTED('Custom Calendar Table')
                )
VAR PreviousAvg=CALCULATE(
                    AVERAGEX(
                    VALUES('Custom Calendar Table'[Month]),
                    [Previous]
                    ),ALLSELECTED('Custom Calendar Table')
                )

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]))
// how to calclate sum of all Indivisual Month Name covariance

RETURN Total_of_AllMonths_Covariance
   

 // Divide(Individual_Month_Covariance,Total_of_AllMonths_Covariance)
// to know what portion of the total
// its returnig all 1s when displayed in table with Month Names as row    
--------------------------------------------------
 
Individual Month covariance =

VAR N=COUNTROWS(CALCULATETABLE(VALUES('Custom Calendar Table'[Month]),ALLSELECTED('Custom Calendar Table')))

VAR CurrentAvg=CALCULATE(
                    AVERAGEX(
                    VALUES('Custom Calendar Table'[Month]),
                    [SelectedMeasureType]
                    ),ALLSELECTED('Custom Calendar Table')
                )
VAR PreviousAvg=CALCULATE(
                    AVERAGEX(
                    VALUES('Custom Calendar Table'[Month]),
                    [Previous]
                    ),ALLSELECTED('Custom Calendar Table')
                )

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]))
// how to calclate sum of all Indivisual Month Name covariance

RETURN Individual_Month_Covariance
   ----------------------------------------------------------------------Covariance table screenshot.PNG
 
----------------------------------data-----------------------------------
value 2023value 2022 same periodIndivisual Month covarienceTotal All Months covarienceYearMonth
£2830771672504171303.24224E+123.24224E+1220231
£2603870392356210006.86453E+136.86453E+1320232
£3007823892711566511.88183E+131.88183E+1320233
£2662901432493379852.25061E+132.25061E+1320234
£2914522062663679493.95195E+123.95195E+1220235
£3020322012630763916.32242E+126.32242E+1220236
£2886583742646656041.36184E+121.36184E+1220237
£2928529702666683105.24589E+125.24589E+1220238
£2912088282678149074.55357E+124.55357E+1220239

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors