Forum Discussion
Averagex outcome is not correct using SSAS tabular
Hi everyone, have some issue with my Average outcome, i have a test table:
I have 2 measure, sum 2 and avge 3, the first sum 2 is a simple one= SUM(table(time)-SUM(table(time2) and
the avge 3=Averagex(values(table(bus),sum 2)
the outcome is not correct, its the same as sum 2 but the totals is correct for avge3.
A should be 5.5 and b should be 3.5.
Im using a live connection so selectedvalue is not a options.
thanks for supporting.
second avge 3= A
5 Replies
- AnonymousNot applicable
Hi,yellowold5 I am glad to help you.
Based on your description, the measure you wrote does not return the expected value, calculating the average within each group (the average of all A's and the average of all B's)
You should try this measure:M_avge 3 = CALCULATE(AVERAGEX('table',[avge 3]),FILTER(ALL('table'),'table'[Bus]=MAX('table'[Bus])))
here is my test data:sum 2 = SUM('table'[time])-SUM('table'[time 2]) avge 3 = Averagex(values('table'[bus]),[sum 2])I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- yellowold5Helper I
Hi I got this error: Syntax or semantic error, reported by analysis services; the function max takes an argument that evalutes to numbers or dates and cannot work with values of type string.
- AnonymousNot applicable
Hi,yellowold5 Thank you for your reply.
I've reused the AS model for live connections and I'm not getting any errors with the above code, you can try using selectedvalue() to make sure that the code doesn't report errors
They both achieve the same resultM_avge 3 = CALCULATE(AVERAGEX('Table_1',[avge 3]),FILTER(ALL('Table_1'),'Table_1'[Bus]=MAX('Table_1'[Bus]))) M_avge 4 = CALCULATE(AVERAGEX('Table_1',[avge 3]),FILTER(ALL('Table_1'),'Table_1'[Bus]=SELECTEDVALUE('Table_1'[Bus]))) M_avge 5 = CALCULATE(AVERAGEX('Table_1',[avge 3]),FILTER(ALL('Table_1'),'Table_1'[Bus]=MIN('Table_1'[Bus])))I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.