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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kris_cs1
Frequent Visitor

Grouped Z-Score using dimension from another table

Hi,

These are two of my tables joined on QuestionID:

Screenshot 2023-04-19 082513.png

I want to calculate a Z-Score using the average of all questions within each [Phys Content Area 1] for each student. 

 

I can get the mean for the student per [Phys Content Area 1]:

CALCULATE(AVERAGE(fact_results[ResultPercentage]), ALLEXCEPT(dim_question, dim_question[Phys Content Area 1]))

 

I can get the mean for the cohort per [Phys Content Area 1]:

CALCULATE(AVERAGE(fact_results[ResultPercentage]), ALLEXCEPT(dim_question, dim_question[Phys Content Area 1]), ALLEXCEPT(fact_results, dim_question[Phys Content Area 1]))

 

But calculating the standard deviation is tricker because it first needs to average the results for each student per [Phys Content Area 1] before calculating the standard deviation. CHATGPT gives me this (which I have tried fixing), but I get 'Parameter is not the correct type.'

STDEV.P(
AVERAGEX(
SUMMARIZE(
ALLEXCEPT(fact_results, dim_question[Phys Content Area 1]),
dim_question[Phys Content Area 1],
"TotalResult",
AVERAGE(fact_results[ResultPercentage])
),
[TotalResult]
),
ALLEXCEPT(dim_question, dim_question[Phys Content Area 1])
)

 

 Thank you so much.

 

1 ACCEPTED SOLUTION
kris_cs1
Frequent Visitor

It took me 3 hours of trying various things, but I finally got it working using this measure: 

CALCULATE(STDEVX.P(FILTER(
ADDCOLUMNS(SUMMARIZE(
fact_results,
fact_results[StudentID],
dim_question[Phys Content Area 1]),
"AverageResultPercentageStudent", CALCULATE(AVERAGE(fact_results[ResultPercentage]))
)
, dim_question[Phys Content Area 1] = dim_question[Phys Content Area 1] )
, [AverageResultPercentageStudent]
), ALLEXCEPT(fact_results, dim_question[Phys Content Area 1])

View solution in original post

1 REPLY 1
kris_cs1
Frequent Visitor

It took me 3 hours of trying various things, but I finally got it working using this measure: 

CALCULATE(STDEVX.P(FILTER(
ADDCOLUMNS(SUMMARIZE(
fact_results,
fact_results[StudentID],
dim_question[Phys Content Area 1]),
"AverageResultPercentageStudent", CALCULATE(AVERAGE(fact_results[ResultPercentage]))
)
, dim_question[Phys Content Area 1] = dim_question[Phys Content Area 1] )
, [AverageResultPercentageStudent]
), ALLEXCEPT(fact_results, dim_question[Phys Content Area 1])

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.