Hi Folks,
SO i have a requirement where i have two fields one in the data and one that comes from an externa file which is appended to the data. I need to check both and make the formula field
Fields are Source System and Count.
So this calculated field will display based on the above condition. I have Jan - Dec Count in the data. and three data sources A, B and C/
So i want to do like if [source] ="A" and [count]= 1 then [JanA] elseif [source] ="A" and [count] =2 then [FebA] elseif [source] ="B" and [count] =1 then [Janb] elseif [source] ="B" and [count] =2 then [Febb] elseif [source]= "C" and [count] = 1 then [Janc] elsif elseif [source] ="C" and [count] =2 then [FebC] else 0 endif
But I am not getting the desired output, getting all 0
Hi @SouravKayal,
If I could advise you something in this case don't use the if-else statement. Create a table that contains all the rules that you have mentioned and use the join tool.
It will be easier for you to maintain and in case it will stop working you will be able to easily fix it.
But what about the multiple conditions
Hi,
You can use this table to join your data:
Source | Count | New col |
A | 1 | JanA |
B | 2 | FebA |
B | 1 | JanB |
B | 2 | FebB |
C | 1 | JanC |
C | 2 |
FebC |
everything that wasn't joined should have new column equal to 0.
It will be also easier for you to understand which positions aren't joining as expected and it will be easier for you to correct.
I am not sure why your multiple IF not works but I did my best to recreate your logic.
OK the table will have the condtions but the column is already there in the data. For ex Jan A, Feb B etc how will i get those in the table
Dont forget old friend "Transpose".
Following idea of @Emil_Kos and I agree that it is better to avoid lengthy else if statement.