0と未入力を見分ける

無題

<aside> <img src="/icons/thought-dialogue_gray.svg" alt="/icons/thought-dialogue_gray.svg" width="40px" /> Notionの関数ではなぜか数値の0が未入力として扱われる

無題

</aside>

<aside> <img src="/icons/exclamation-mark_gray.svg" alt="/icons/exclamation-mark_gray.svg" width="40px" /> テキストの”0”は未入力ではない

無題

</aside>

<aside> <img src="/icons/checkmark_gray.svg" alt="/icons/checkmark_gray.svg" width="40px" /> format関数で数値をテキストに変換すれば未入力として扱われない

無題

</aside>

空文字と未入力を使い分ける

無題

<aside> <img src="/icons/thought-dialogue_gray.svg" alt="/icons/thought-dialogue_gray.svg" width="40px" /> 未入力を除いて平均を計算したくても未入力の行に0が入ってしまい、3と6と0の平均になってしまう

length(prop("テキスト"))

Untitled

</aside>

<aside> <img src="/icons/thought-dialogue_gray.svg" alt="/icons/thought-dialogue_gray.svg" width="40px" /> 未入力の行に空文字(””)を出力するとそのプロパティがテキストとして扱われ、平均を計算できない

if(empty(prop("テキスト")), "", length(prop("テキスト")))

Untitled

</aside>

<aside> <img src="/icons/checkmark_gray.svg" alt="/icons/checkmark_gray.svg" width="40px" /> 空文字(””)の代わりにtoNumber("")を出力すると未入力として扱われる。プロパティも数値として扱われるので平均を計算できる。

if(empty(prop("テキスト")), toNumber(""), length(prop("テキスト")))

Untitled

</aside>