cross join - Trying to calculate quartiles in MDX -
my data looks this:
id |personid |companyid |dateid |throughput |amounttype 33f467ac-f35b-4f24-a05b-fc35cf005981 |7 |53 |200802 |3 |0 04ee0ff0-511d-48f5-aa58-7600b3a69695 |18 |4 |201309 |5 |0 ab058aa5-6228-4e7c-9469-55827a5a34c3 |25 |69 |201108 |266 |0
with around million rows. columns names *id refers other tables, can used dimensions.
i have olap cube column throughput measure , rest dimensions.
i want calculate quartile 1 , 3 of throughput measure.
i followed guide: https://electrovoid.wordpress.com/2011/06/24/ssas-quartile/ post: calculating quartiles in analysis services
from tried use mdx query:
with set selection ([dates].[year].&[2014],[dates].[month].&[1]) set [nonemptyids] nonempty( [throughputid].[id].[id] *[throughputid].[id].[id].allmembers , {[measures].[throughput]} * [selection] ) set [throughputdata] order ( [nonemptyids], [measures].[throughput], basc ) member [measures].[rowcount] count (throughputdata) member [measures].[i25] ( .25 * ( [rowcount] - 1 ) ) + 1 member [measures].[i25lo] fix([i25]) - 1 member [measures].[i25rem] ([i25] - fix([i25])) member [measures].[n25lo] (throughputdata.item([i25lo]), [throughput]) member [measures].[n25hi] (throughputdata.item([i25lo] + 1), [throughput]) member [measures].[quartile1] [n25lo] + ( [i25rem] * ( [n25hi] - [throughput] )) select selection on 0, [measures].[quartile1] on 1 (select [dates].[y-h-q-m].members on 0 [throughput])
but get: 'query (6, 7) id hierarchy used more once in crossjoin function.'
i quite new olap , mdx. ideas what's wrong , how should calculate quartiles correct?
i read somewhere needed id dimensions able set values instead of aggregated values when calculating quartiles...
culprit following piece of code:
set [nonemptyids] nonempty( [throughputid].[id].[id] *[throughputid].[id].[id].allmembers , {[measures].[throughput]} * [selection] )
you can't use same hierarchy more once in cross-join. here have used [throughputid].[id]
twice. instead try below:
set [nonemptyids] nonempty( [throughputid].[id].[id].allmembers , {[measures].[throughput]} * [selection] )
Comments
Post a Comment