how to get previous value in a fact table for a measure in mdx

38 Views Asked by At

I want to write an mdx query with a calculated Measure. Here is my fact table:

my case

How to implement a mesaure with the rule below :

If CurrentAtt != PreviousAtt then PreviousValue

else CurrentValue

Thank you so much!

any suggestion please ?

1

There are 1 best solutions below

0
whytheq On

There are functions PrevMember and MemberValue in MDX that you could use.

To implement the logic you could use IIF

So something like the following:

IIF(
[Attrib].CURRENTMEMBER.MemberValue <> [Attrib].CURRENTMEMBER.PREVMEMBER.MemberValue
, ([Attrib].CURRENTMEMBER.PREVMEMBER, [Mesure1])
, ([Attrib].CURRENTMEMBER, [Mesure1])
)