> For the complete documentation index, see [llms.txt](https://help.adalo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.adalo.com/ja/component-basics/how-to-create-a-custom-math-formula/complex-calculations.md).

# 複雑な計算

#### **1. `*100/100` を使用して最も近い百分の一に数値を丸める**

数値を手動で小数点以下2桁に丸めたい場合、それを100倍して丸め、その後再度100で割ることができます。例えば、数値12.34567を小数点以下2桁に丸める場合：

```plaintext
ROUND(12.34567 * 100) / 100
```

この計算は以下のように機能します：

* `12.34567` を100倍する → `1234.567`
* 最も近い整数に丸める → `1235`
* 元のスケールに戻すために100で割る → `12.35`

***

#### **2. 増減率の計算**

昨年の収益と今年の収益がある場合、増加率を計算したいとします：

```plaintext
((今年の収益 - 昨年の収益) / 昨年の収益) * 100
```

この式は以下を行います：

* 昨年の収益を今年の収益から引いて差を求める。
* その差を昨年の収益で割って変化を小数で計算する。
* 結果をパーセンテージに変換するために100を掛ける。

***

#### **3. 複利計算式**

元本、利率、期間（例：年数）がある場合、複利を計算するために以下の式を使用できます：

```plaintext
元本 * (1 + 利率 / 100)^期間
```

例えば、年利率5%で1,000ドルを3年間投資する場合、式は以下のようになります：

<pre class="language-plaintext"><code class="lang-plaintext"><strong>1000 * (1 + 5 / 100)^3
</strong></code></pre>

これは3年間の複利を考慮した後の総額を計算します。

***

#### **4. 丸めと他の関数の組み合わせ**

計算されたパーセンテージを小数点第1位に丸めたい場合があります。例えば、タスクの完了率を計算して丸めたい場合：

```plaintext
ROUND((完了したタスク / 総タスク) * 100, 1)
```

この式は以下を行います：

* 完了したタスクの数を総タスクで割って、完了率を小数で取得する。
* 100を掛けてパーセンテージに変換する。
* 結果を小数点第1位に丸める。

***

#### **5. ユーザーの時間に基づいて時間を調整**

ユーザーの時間に基づいて現在の日付を一部調整したい場合、次の式を使用できます：

```plaintext
現在の日付 + ((24 - ユーザーの時間) / 24)
```

この式は以下のように機能します：

* 24から`ユーザーの時間`を引いて、その日の残り時間を取得する。
* 24で割って残り時間を日の一部の分数に変換する。
* その日の一部の分数を`現在の日付`に加えて時間を調整する。

***

#### **6. 簡単なパーセンテージ計算**

ある数値（`部分`）が合計（`合計`）の何パーセントかを計算したい場合：

```plaintext
(部分 / 合計) * 100
```

例えば、50個のうち30個のタスクを完了した場合、式は以下のようになります：

```plaintext
(30 / 50) * 100 → 60%
```

***

#### **7. 日付に日数を追加する**

現在の日付に特定の日数を追加して新しい日付を計算するには、以下を使用できます：

```plaintext
現在の日付 + 日数
```

例えば、今日の日付に7日を追加する場合:

```plaintext
現在の日付 + 7
```

これにより、今から7日後の日付が得られます。

***

#### **8. 日付間の日数を計算する**

2つの日付間の日数を計算するには、以下を使用できます:

{% code overflow="wrap" %}

```plaintext
INT(End_Date - Start_Date/Time) または 
INT(End_Date/Time - Start_Date/Time) または 
End_date - Start_Date
```

{% endcode %}

**例2: 日付と時刻**

```
End_Date = 2025-02-01 15:45
Start_Date = 2025-01-23 10:30
End_Date - Start_Date = 9.21875日 (9日間と約5.25時間)
INT(9.21875) = 9
結果: 9日(切り捨て、部分日を無視)
```

**例1: 日付のみ**

```
End_Date = 2025-02-01
Start_Date = 2025-01-23
End_Date - Start_Date = 9
INT(9) = 9
結果: 9日
```

この式

* 2つの日付または日時の差を計算します。結果は通常、**小数点付きの日数**で、整数部分が完全な日数を表し、小数部分が時間の差を表します。
* `INT` 関数を適用して、小数の結果を切り捨て(切り下げ)て最も近い下位の整数にします。例:
  * 差が `2.75` 日の場合、`INT` は `2` 日を返します。
  * 差が `-1.25` 日の場合、`INT` は `-2` 日を返します。

この式:

#### **主な制限**:

この方法は1日の小数部分を破棄するため、正確な時間差(例: 9.22日)が必要な場合には適していません。より微妙な計算には、`ROUND` や `DATEDIF` のような代替手法を使用してください。

***

**9. 割引額を計算する**

商品の割引価格を計算したい場合、割引額を元の価格から引き算します:

```plaintext
元の価格 - (元の価格 * 割引率 / 100)
```

例えば、商品が$100で20%の割引がある場合、式は次のようになります:

```plaintext
100 - (100 * 20 / 100) → $80
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.adalo.com/ja/component-basics/how-to-create-a-custom-math-formula/complex-calculations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
