cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Chi Square Test in DAX - Getting wrong p-values

Year

Question_Number

IC

Organization

Positive

2019

1

                Agency

Agency

85

2019

2

                Agency

Org1

  96

2020

1

                Agency

Org2

88

2020

2

                Agency

Org3

95

2021

1

                 Agency

Org4

90

2021

1

Agency

Org5

83

 

I would like to calculate the chi square p-value between the avarage agency positive rating and a specific organization (e.x. org1) for year 2020. I have question number as a filter.

The table above shows structure of my data.

 

I have my DAX code that I wrote below, but the p value it is giving me is not correct. I used the same data and conducted a chi square test and it renders different p-value- please advise.

 

 

Significance vs Agency =

var _year = 2020

var _question_no = SELECTEDVALUE(Sheet1[Question_Number])

var _actual = CALCULATE(AVERAGE(Sheet1[Positive]),Sheet1[Year] =_year)

var _expected = CALCULATE(AVERAGE(Sheet1[Positive]),

        FILTER(ALL(Sheet1),

        Sheet1[Year]=_year && Sheet1[IC]="Agency"

        && Sheet1[Organization]="Agency"  

        && Sheet1[Question_Number]=_question_no

))

VAR ChiStat = ((_actual-_expected)^2)/_expected

--VAR DegreesFreedom = (COUNT(Sheet1[Positive])-1)

RETURN

    CHISQ.DIST.RT(ChiStat,5)

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

A chi2 test can test 2 things:

 

1) distribution goodness-of-fit and

2) whether 2 categorical variables are independent.

 

What are you trying to achieve here? I can't see any relevance of what you're doing to the above.

 

Here's an excerpt from When to Use a Chi-Square Test (With Examples) - Statology:

daXtreme_0-1664141110267.png

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors