Forum Discussion
Compare text value with previous month
Hello,
I want to compare Code which is Text with previous month. Each code can come is unique like in January this code can only comes one not more than that. Same code can come in next month but it can only come only once there as well.
My tale looks like below:
| Month | Code |
| March | 112 |
| March | 123 |
| April | 866 |
| April | 112 |
| May | 656 |
| May | 234 |
I want to create a new column and comapre these codes with previous month. If For example code 112 in April is also in previous month then the value against it should be like unchanged. If the codeis not in previous month then it should show new else it should show gone. I am attaching a outcome table as well along with the criteria.
| Month | Code | Outcome |
| March | 112 | GONE |
| March | 123 | GONE |
| April | 866 | NEW |
| April | 112 | UNCHANGED |
| May | 656 | NEW |
| May | 234 | NEW |
If Exist in March and April: 'Unchanged'
If Exist in March Not Exist April: 'Gone'
if don't exist in march and exist in April: 'New"
It would be highly appreciated if I can get the response.
Thank you
2 Replies
- amitchandak
Super User
Junaid11 , Try like
New column =
var _date = [Date]
var _code = maxx(filter(Table,eomonth(_date,0) = eomonth([Date],0) ),[Code])
return
Switch(True(),[Code] = _code, "Unchanged",
Not(isblank(_code)) && [Code]<> _code, "New" , "Gone")
- Junaid11
Helper V
Hello amitchandak ,
The code is not working I am getting below outcome which is not similar to outocme I have mentioned.