Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I'm trying to find a way to visualize in a table when a data point is an outlier, for people to go and check it. I'm thinking perhaps a z-score column with conditional formatting is my best bet, but I'm having a little trouble conceptualizing how to calculate a z score when I need to group the data by multiple criteria.
I need to group the data by TRT_ID, Metric Type, and Completed = Yes for each Z-score. So... for row 1, I'd need (8566 - Mean of "Yes" Electricity for TRT 19) / (Stand.Dev. of "Yes" Electricity for TRT 19), then for that to cascade down through the different TRT_ID and Metric_Type combinations. I can't seem to wrap my brain around how to write that... and whether or not it should be a custom column or a measure?
Sample data in post below because of character limit issues
Solved! Go to Solution.
I solved my own problem with three measures:
I solved my own problem with three measures:
I still don't have a solution to this, the one provided above doesn't seem to be giving the right numbers.
I am playing around with pivoting the table with the metric types as separate columns so that the data only has to be grouped by TRT_ID & Completed = Yes . There would then be a z-score column for each metric type. Below is a sample of just electricity; I figure it would be the same for all the other metrics, just changing the columns that the use data is being pulled from.
Sample Table:
TRT_ID | Date | Electricity Use | Electricity Use Complete | Electricity Z-Score |
19 | January, 2022 | 8566 | Yes | |
19 | February, 2022 | 8052 | Yes | |
19 | March, 2022 | 9334 | Yes | |
19 | April, 2022 | 8681 | Yes | |
19 | May, 2022 | 7529 | Yes | |
19 | June, 2022 | 9166 | Yes | |
19 | July, 2022 | 9350 | Yes | |
19 | August, 2022 | 11342 | Yes | |
19 | September, 2022 | No | ||
22 | January, 2022 | 7405.86 | Yes | |
22 | February, 2022 | 7166.25 | Yes | |
22 | March, 2022 | 12397.47 | Yes | |
22 | April, 2022 | 5691.83 | Yes | |
22 | May, 2022 | 6619.3 | Yes | |
22 | June, 2022 | 5988.94 | Yes | |
22 | July, 2022 | 6640.56 | Yes | |
22 | August, 2022 | 6154.99 | Yes | |
22 | September, 2022 | 0 | No |
TRT_ID | Metric_Type | Date | Use | Completed | UseZ-score |
19 | Electricity | January, 2022 | 8566 | Yes | |
19 | Electricity | February, 2022 | 8052 | Yes | |
19 | Electricity | March, 2022 | 9334 | Yes | |
19 | Electricity | April, 2022 | 8681 | Yes | |
19 | Electricity | May, 2022 | 7529 | Yes | |
19 | Electricity | June, 2022 | 9166 | Yes | |
19 | Electricity | July, 2022 | 9350 | Yes | |
19 | Electricity | August, 2022 | 11342 | Yes | |
19 | Electricity | September, 2022 | No | ||
19 | Natural Gas | January, 2022 | 166.72 | Yes | |
19 | Natural Gas | February, 2022 | 138.16 | Yes | |
19 | Natural Gas | March, 2022 | 338.44 | Yes | |
19 | Natural Gas | April, 2022 | 47.12 | Yes | |
19 | Natural Gas | May, 2022 | 10 | Yes | |
19 | Natural Gas | June, 2022 | 0.36 | Yes | |
19 | Natural Gas | July, 2022 | 0.71 | Yes | |
19 | Natural Gas | August, 2022 | 0.36 | Yes | |
19 | Natural Gas | September, 2022 | No | ||
22 | Electricity | January, 2022 | 7405.86 | Yes | |
22 | Electricity | February, 2022 | 7166.25 | Yes | |
22 | Electricity | March, 2022 | 12397.47 | Yes | |
22 | Electricity | April, 2022 | 5691.83 | Yes | |
22 | Electricity | May, 2022 | 6619.3 | Yes | |
22 | Electricity | June, 2022 | 5988.94 | Yes | |
22 | Electricity | July, 2022 | 6640.56 | Yes | |
22 | Electricity | August, 2022 | 6154.99 | Yes | |
22 | Electricity | September, 2022 | No | ||
24 | Electricity | January, 2022 | 3935 | Yes | |
24 | Electricity | February, 2022 | 4557 | Yes | |
24 | Electricity | March, 2022 | 4121 | Yes | |
24 | Electricity | April, 2022 | 3883 | Yes | |
24 | Electricity | May, 2022 | 4204 | Yes | |
24 | Electricity | June, 2022 | 4215 | Yes | |
24 | Electricity | July, 2022 | 4143 | Yes | |
24 | Electricity | August, 2022 | 4115 | Yes | |
24 | Electricity | September, 2022 | No | ||
26 | Electricity | January, 2022 | 5817 | Yes | |
26 | Electricity | February, 2022 | 5583 | Yes | |
26 | Electricity | March, 2022 | 6083 | Yes | |
26 | Electricity | April, 2022 | 6072 | Yes | |
26 | Electricity | May, 2022 | 6430 | Yes | |
26 | Electricity | June, 2022 | 6552 | Yes | |
26 | Electricity | July, 2022 | 7245 | Yes | |
26 | Electricity | August, 2022 | 7785 | Yes | |
26 | Electricity | September, 2022 | No | ||
27 | Electricity | January, 2022 | 6791 | Yes | |
27 | Electricity | February, 2022 | 9008 | Yes | |
27 | Electricity | March, 2022 | 7221 | Yes | |
27 | Electricity | April, 2022 | 8333 | Yes | |
27 | Electricity | May, 2022 | 8807 | Yes | |
27 | Electricity | June, 2022 | 8843 | Yes | |
27 | Electricity | July, 2022 | 8905 | Yes | |
27 | Electricity | August, 2022 | 9012 | Yes | |
27 | Electricity | September, 2022 | No | ||
30 | Electricity | January, 2022 | 3886 | Yes | |
30 | Electricity | February, 2022 | 4234 | Yes | |
30 | Electricity | March, 2022 | 4609 | Yes | |
30 | Electricity | April, 2022 | 3751 | Yes | |
30 | Electricity | May, 2022 | 4288 | Yes | |
30 | Electricity | June, 2022 | 4286 | Yes | |
30 | Electricity | July, 2022 | 5234 | Yes | |
30 | Electricity | August, 2022 | 5055 | Yes | |
30 | Electricity | September, 2022 | No | ||
34 | Electricity | January, 2022 | 8534 | Yes | |
34 | Electricity | February, 2022 | 7708 | Yes | |
34 | Electricity | March, 2022 | 6962 | Yes | |
34 | Electricity | April, 2022 | 6737 | Yes | |
34 | Electricity | May, 2022 | 6737 | Yes | |
34 | Electricity | June, 2022 | 6520 | Yes | |
34 | Electricity | July, 2022 | 6737 | Yes | |
34 | Electricity | August, 2022 | 6737 | Yes | |
34 | Electricity | September, 2022 | No | ||
34 | Water | January, 2022 | 2.04 | Yes | |
34 | Water | February, 2022 | 1.84 | Yes | |
34 | Water | March, 2022 | 2.04 | Yes | |
34 | Water | April, 2022 | 1.97 | Yes | |
34 | Water | May, 2022 | 1.97 | Yes | |
34 | Water | June, 2022 | 1.91 | Yes | |
34 | Water | July, 2022 | 1.97 | Yes | |
34 | Water | August, 2022 | 1.97 | Yes | |
34 | Water | September, 2022 | No | ||
41 | Electricity | January, 2022 | 1852 | Yes | |
41 | Electricity | February, 2022 | 3142 | Yes | |
41 | Electricity | March, 2022 | 1626 | Yes | |
41 | Electricity | April, 2022 | 1886 | Yes | |
41 | Electricity | May, 2022 | 1649 | Yes | |
41 | Electricity | June, 2022 | 1070 | Yes | |
41 | Electricity | July, 2022 | 1295 | Yes | |
41 | Electricity | August, 2022 | 1419 | Yes | |
41 | Electricity | September, 2022 | No | ||
50 | Electricity | January, 2022 | 9590 | Yes | |
50 | Electricity | February, 2022 | 6835 | Yes | |
50 | Electricity | March, 2022 | 6064 | Yes | |
50 | Electricity | April, 2022 | 5126 | Yes | |
50 | Electricity | May, 2022 | 6359 | Yes | |
50 | Electricity | June, 2022 | 5432 | Yes | |
50 | Electricity | July, 2022 | 4858 | Yes | |
50 | Electricity | August, 2022 | 4511 | Yes | |
50 | Electricity | September, 2022 | No | ||
54 | Electricity | January, 2022 | 6588 | Yes | |
54 | Electricity | February, 2022 | 4968 | Yes | |
54 | Electricity | March, 2022 | 5310 | Yes | |
54 | Electricity | April, 2022 | No | ||
54 | Electricity | May, 2022 | 12744 | Yes | |
54 | Electricity | June, 2022 | 8946 | Yes | |
54 | Electricity | July, 2022 | 9252 | Yes | |
54 | Electricity | August, 2022 | 11196 | Yes | |
54 | Electricity | September, 2022 | 12348 | Yes |
Hi @Rdata ,
You can try this code to calcualte you want.
Z-score =
VAR _f =
FILTER(
ALLEXCEPT( 'Table', 'Table'[TRT_ID], 'Table'[Metric_Type] ),
[Completed] = "yes"
)
VAR _avg =
AVERAGEX( _f, [Use] )
VAR _s =
STDEVX.P( _f, [Use] )
RETURN
DIVIDE( MAX( 'Table'[Use] ) - _avg, _s )
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am not sure if this is right, following my requirements of grouping by TRT_ID --> Year --> Metric Type. I did a manual run of the numbers in excel and the z-score in the table for electricity & 2022/1/1 should be -.40929, not .9816