Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I am rather new to Power BI and I am currently trying to use DAX codes to generate a Measure of Z-Scores with multiple filters.
The report is using Direct Query to a SQL database.
Here is an example of part of the table:
I would like to categorize the Average Cycle Times (ACT) by Devices, and create a Measure that shows the Z-Scores of these ACTs based on averages and standard deviations for each Device.
However, I also want to ignore all the 0 entries in the ACT column.
Here is my DAX code for the Z-Scores without ignoring all the 0 entries:
ACT_Z = var mean = CALCULATE(AVERAGE('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device])) var deviation = CALCULATE(STDEV.P('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device])) return (SUM('Test2'[ACT])-mean)/deviation
And here is the result (I don't know if it is correct, but I think it is):
And when I add the filter for ignoring the 0s:
ACT_Z = var mean = CALCULATE(AVERAGE('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device]),FILTER('Test2','Test2'[ACT]>0)) var deviation = CALCULATE(STDEV.P('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device]),FILTER('Test2','Test2'[ACT]>0)) return (SUM('Test2'[ACT])-mean)/deviation
Here is what I got:
I can't figure out what the problem is, and if my previous DAX code was correct.
Would someone please take a look at it? I hope this is a quick fix. Thank you!
Solved! Go to Solution.
@Anonymous - Please try to reconfigure like this and let us know whether it works:
ACT_Z = var mean = CALCULATE( AVERAGE('Test2'[ACT]), FILTER( ALLEXCEPT('Test2','Test2'[Device]), 'Test2'[ACT]>0 ) ) var deviation = CALCULATE( STDEV.P('Test2'[ACT]), FILTER( ALLEXCEPT('Test2','Test2'[Device]), 'Test2'[ACT]>0 ) ) return DIVIDE( SUM('Test2'[ACT])-mean, deviation )
Hope this helps,
Nathan
hi @Anonymous
Would agree with @Anonymous
Your first part of dax z-score calculation is correct, but its better to do the filter on the first part itself without trying to call twice the code.
All the best
@Anonymous assume you want to exclude zero entries in all the calculations
ACT_Z = var mean = CALCULATE(AVERAGE('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device]),Test2'[ACT]>0) var deviation = CALCULATE(STDEV.P('Test2'[ACT]),ALLEXCEPT('Test2','Test2'[Device]),Test2'[ACT]>0) return (SUM('Test2'[ACT])-mean)/deviation
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous - Please try to reconfigure like this and let us know whether it works:
ACT_Z = var mean = CALCULATE( AVERAGE('Test2'[ACT]), FILTER( ALLEXCEPT('Test2','Test2'[Device]), 'Test2'[ACT]>0 ) ) var deviation = CALCULATE( STDEV.P('Test2'[ACT]), FILTER( ALLEXCEPT('Test2','Test2'[Device]), 'Test2'[ACT]>0 ) ) return DIVIDE( SUM('Test2'[ACT])-mean, deviation )
Hope this helps,
Nathan
Thank you, that worked perfectly.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
74 | |
72 | |
39 | |
28 | |
27 |
User | Count |
---|---|
97 | |
97 | |
58 | |
45 | |
42 |