'How many 1's in last 4 days?

enter image description here

I would like to count or sum how many 1's in last four days (1/1 to 1/4) for each name (A, B, C, D) in Informatica Developer. Advise please!!



Solution 1:[1]

simply create an exp transformation and a new output port. Formula should be like this-

o_how_many_1s= day1 + day2+day3+day4

Now, you said, all the day* values can be wither 0 or 1, so adding them will give you count of 1s.

If you have null in these fields, then you can use IIF(isnull(day1),0,day1) logic while adding.
If you have some numbers other than 0,1, then, then you need to use something specific like this

o_how_many_1s= IIF(day1=1,1,0) + IIF(day2=1,1,0)+IIF(day3=1,1,0)+IIF(day4=1,1,0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Koushik Roy