<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> This example database uses the Pythagorean Theorem to solve for the missing side of any right triangle. Two of the three side lengths must be provided; the Calculator property will solve for the missing one.

Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter

</aside>

Pythagorean Theorem

// Compressed
if(empty(prop("Hypotenuse")) and empty(prop("Side 1")) or empty(prop("Hypotenuse")) and empty(prop("Side 2")) or empty(prop("Side 1")) and empty(prop("Side 2")), "Not enough information!", if(empty(prop("Hypotenuse")), "Hypotenuse: " + format(round(sqrt(prop("Side 1") ^ 2 + prop("Side 2") ^ 2) * 100) / 100), if(empty(prop("Side 1")), "Side 1: " + format(round(sqrt(prop("Hypotenuse") ^ 2 - prop("Side 2") ^ 2) * 100) / 100), "Side 2: " + format(round(sqrt(prop("Hypotenuse") ^ 2 - prop("Side 1") ^ 2) * 100) / 100))))

// Expanded
if(
    empty(
        prop("Hypotenuse")
    ) and empty(
        prop("Side 1")
    ) or empty(
        prop("Hypotenuse")
    ) and empty(
        prop("Side 2")
    ) or empty(
        prop("Side 1")
    ) and empty(
        prop("Side 2")
    ),
    "Not enough information!",
    if(
        empty(
            prop("Hypotenuse")
        ),
        "Hypotenuse: " +
        format(
            round(
                sqrt(
                    prop("Side 1")^2 + prop("Side 2")^2
                ) * 100
            ) / 100
        ),
        if(
            empty(
                prop("Side 1")
            ),
            "Side 1: " + 
            format(
                round(
                    sqrt(
                        prop("Hypotenuse")^2 - 
                        prop("Side 2")^2
                    ) * 100
                ) / 100
            ),
            "Side 2: " + 
            format(
                round(
                    sqrt(
                        prop("Hypotenuse")^2 - 
                        prop("Side 1")^2
                    ) * 100
                ) / 100
            )
        )
    )
)

© Thomas Frank