Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

MDX Calculation for a complex query

$
0
0

Hi,

I have a little bit of experience using MDX queries using SSAS 2012, but this time I found a complex problem to solve with this calculation. I have the following query (this query is used to calculate an indicator of efficiency in the company)

SELECT A.atribute_number
            ,SUM(DISTINCT A.atribute_value)
FROM fact_table A
INNER JOIN dim_table B ON (A.keyValue = B.keyValue)
WHERE B.value = 1 AND A.value2 < 1 AND B.range IN (2,5,6,5)
AND A.contact_id IN (SELECT contact_id
                                   FROM fact_table
                                  WHERE B.range = 4
                                  AND value = 2);

I have already done some MDX queries  to try to get same results, but I couldn't get same resut yet. I read some books and tutorials that whichever SQL query should be replicate using a MDX to query (Is that true?).

 My strategy to solve this query is as following:

1) The agregations were calculated previously in the cube definition, so nothing to do in this part (SELECT section in the query)

2) In the Filters (WHERE section in the query), I tried to incude that conditions in the MDX WHERE section, but I have no idea how to manage the condition A.value < 1, because in a MDX query there is no "<" conditional, also I have no idea how to translate the subquery section (.. AND A.contact_id IN (SELECT contact_id... ) .. ).

Currently, My goal is to replicate the SQL functionality using MDX.

I have used MDX to calculate Measures, but I am lost trying to solve/translate this query. (Sorry if something wrong with my approach to solve this issue, but I'm new with MDX :D)

Any kind of advice or suggestion will be appreciated.

thanks in advance.


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>