Google Sheets – Array Formula to Show Leading Zero

google sheetsgoogle-sheets-arrayformula

I have a Google Sheet where an array formula in Column I creates a video name based on the content entered into columns A+B+C+D.
Column C is the number of the video. For some videos, I need a leading zero in the name and for others, not. I don't want to format column C as text – I need to leave this column formatted as a number. I also had to format Column C to add a full stop after the number as it is important this is part of the number in the name. I can't rely on editors to always remember to add the full stop.

What do I add to the array formula so it correctly reflects the content in Column C, where some videos will have a leading zero (like 01. and some not, like 0.)

=ARRAYFORMULA(IF($E2:$E="Yes", $D2:$D, IF(ISBLANK($A2:$A), "", $A2:$A & " - ") & IF(ISBLANK($B2:$B), "", $B2:$B & " - ") & IF(ISBLANK($C2:$C), "", $C2:$C & ". ") & $D2:$D))

Here is my Google Test Sheet.
https://docs.google.com/spreadsheets/d/1AIdZmFqtojG_7OLY_twJhmFewVTyoFAsozzbeSeHun4/edit?usp=sharing

Best Answer

You can use either the following formulas instead

=ARRAYFORMULA(IF($E2:$E="Yes", $D2:$D, IF(ISBLANK($A2:$A), "", $A2:$A & " - ") & IF(ISBLANK($B2:$B), "", $B2:$B & " - ") & IF(ISBLANK($C2:$C), "", TEXT($C2:$C,"00. ")) & $D2:$D))  

OR

=ARRAYFORMULA(IF($E2:$E="Yes", $D2:$D, IF(ISBLANK($A2:$A), "", $A2:$A & " - ") & IF(ISBLANK($B2:$B), "", $B2:$B & " - ") & IF(ISBLANK($C2:$C), "", TEXT($C2:$C,"00") & ". ") & $D2:$D))

(Either of the above formulas will format all single digit numbers in column C having a leading 0. This will provide even better consistency to your results than the one you are asking for, as in "Big battles! - 01. Bass drum" instead of "Big battles! - 1. Bass drum")