0.5AL,,,,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL,1.0BL
SUM(IF(RIGHT(B5:AF5,2)="BL",1,0)*(VALUE(IF(LEFT(B5:AF5,3)="",0,(LEFT(B5:AF5,3))))))
- There are empty cells in this row.We could do a VALUE(LEFT(B5:AF5,3)) to get the numerical value. But we will get an error if the cell is empty.
- The cells contain strings and not numbers. The typical "sumif" applies conditions and sum on the same range. This is not what we want because we want to condition on the substring instead of the whole string.
VALUE(IF(LEFT(B5:AF5,3)="",0,(LEFT(B5:AF5,3))))
IF(RIGHT(B5:AF5,2)="BL",1,0)
This will give us the logical condition of 1 if the condition is met and 0 otherwise.
By multiplying the two we will have a range of values conditioned on the existance of the substring "AL" or "BL" and we can get the sum by adding them up. This made me interested on including this feature in functions.
I was asking around for alternative solutions here are some alternative solutions:
1. An improved version can be done with the following formula:
I was asking around for alternative solutions here are some alternative solutions:
1. An improved version can be done with the following formula:
SUM(IF(RIGHT(B5:AF5,2)="BL","BL",VALUE(IF(LEFT(B5:AF5,3))),0))
2. As pointed out by one of my friends, he suggested using SQL to do this. The pseudocode is as follows:
select substr(column, 3,2), sum(column, 0,3) from table group by substr(column, 3,2);
No comments:
Post a Comment