# Divergence / Difference

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

• # Divergence / Difference

Hello!

I started a thread and thought I solved my problem, but unfortunately now I only know that is a "Rules" Topic.

I would like to compair two periods and get the difference.
I tried it according to this example jedox.com/wikipalo/de/index.php/Abweichungen with the biker Database, but I can not get the rule to work.

['Vorperiode'] = PALO.DATA("Biker", "Orders", PALO.ENAME("Biker", "Years", PALO.EINDEX("Biker", "Years", !'Years') - VALUE(PALO.DATA("Biker", "#_Months", "VJ_Flag", !'Months'))), PALO.DATA("Biker", "#_Months", "Vorperiode", !'Months'), !'Customers', !'Channels', !'Orderlines', "Units", !'Products', !'Months')

I tried to get the Units, but I'm quite sure that the rule is not correct!
Thank you for your help!
• # RE: Divergence / Difference

Hi outlaw77,

If you are trying to compare differences between months and you don't need to calculate across years then you could build additional consolidations to calculate the difference between the periods.

If you do need to calculate the difference between months across years then perhaps a rule like the following might help.

Using an attribute to track the previous month the rule also checks to see if it needs to roll across years.

### Source Code

1. ['Difference'] = N:['Units'] - PALO.DATA("Biker","Orders",IF((!'Months') == "Jan",PALO.ENAME("Biker","Years",PALO.EINDEX("Biker","Years",!'Years') - 1),!'Years'),!'Customers',!'Channels',!'Orderlines',!'Datatypes',"Units",!'Products',PALO.DATA("Biker","#_Months","Previous",!'Months'))

This many not fit your needs exactly but perhaps the concept may be of some help.

Rod