Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have data like below:
ID | Month | Value | Category | Difference |
A | January | 10 | - | - |
A | February | 15 | Increase | 5 |
A | March | 20 | Increase | 10 |
A | April | 25 | Increase | 15 |
B | January | 40 | - | - |
B | February | 32 | Decrease | - 8 |
B | March | 24 | Decrease | -16 |
B | April | 16 | Decrease | -24 |
C | January | - | - | - |
C | February | - | - | - |
C | March | 7 | New | 7 |
C | April | 14 | New | 14 |
Here I am comparing values in Field 1.
Explanation: I need to compare value of each ID with January data and categorize into groups.
Like, For A, February value is more than January Value ---> Increase category
For B, February value is less than January Value ---> Decrease category
For C, it is not in January, so it is new category ----> New
Along with this category field, I need to display the difference between each month and January month.
Can anyone help me with logic/script?
This should be easiest to achieve with a mapping load, I believe. Code might not be 100% accurate but you should be able to get it working, I'm sure.
Map:
Mapping Load ID, Value
From YourTable
Where Month = 'January';
Load *, Value - ApplyMap('Map',ID) as Difference, if(isnull(ApplyMap('Map',ID)),'New',if(ApplyMap('Map',ID)>Value,'Decrease','Increase'))
This should be easiest to achieve with a mapping load, I believe. Code might not be 100% accurate but you should be able to get it working, I'm sure.
Map:
Mapping Load ID, Value
From YourTable
Where Month = 'January';
Load *, Value - ApplyMap('Map',ID) as Difference, if(isnull(ApplyMap('Map',ID)),'New',if(ApplyMap('Map',ID)>Value,'Decrease','Increase'))
Sorry for late reply. I followed the above method and its working fine. Thank you so much