Pergunta

I am quite new to MDX and I need to write a query that gives me the day difference between two dates. The problem is that the dates exist on two different rows in my data. For example:

My Fact table:

SEAL | STARTDATE | PROCESS | FK_DATE_KEY  
1    | 2012-10-22|    A    | 20121022
1    | 2012-10-24|    B    | 20121024
2    | 2012-10-22|    A    | 20121022
2    | 2012-10-26|    B    | 20121026

What I need returned is :

SEAL | AGE_IN_DAYS
1    |      2
2    |      4

Please help.... I have a date dimension that relates to my FK_DATE_KEY

Foi útil?

Solução

If you are new to MDX, you shouldn't try to do this problem using only MDX. This particular problem is much easier if you write it under SQL and use that data in your Analysis Services.

So, the easiest and nicest way to do this problem is to write a view which returns the same data you gave in your question. (SEAL | AGE_IN_DAYS) Then you are able to insert these data in your Data Source View (if you choose 'new named query', you can fetch table-valued functions too, not only views and tables)

Hope it helps!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top