> For the complete documentation index, see [llms.txt](https://docs.ngsurvey.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ngsurvey.com/ar/projects/import-export/xlsform/wrqh-alastbyan/alhsabat.md).

# الحسابات

تُستخدم الحسابات لإنشاء حقول مخفية تقوم تلقائيًا بحساب قيم بناءً على إجابات أخرى في النموذج.

في XLSForm، تُعرّف الحسابات باستخدام `نوع السؤال calculate` هذه الحقول لا تُعرض للمستخدم، لكنها تعمل في الخلفية وتخزن النتائج لاستخدامها لاحقًا أو لتحليلها.

في ngSurvey، سيتم حفظ القيم المحسوبة كحقول مخفية وتضمينها في مخرجات بيانات النموذج، مثلها مثل الإجابات الأخرى.

## 🔢 كيفية تعريف حساب

لإنشاء حساب:

1. استخدم نوع `نوع السؤال calculate` في `ورقة survey` في ورقة survey.
2. عيّن اسمًا للحقل.
3. استخدم `عمود calculation` لتعريف المنطق.
4. اختياريًا، استخدم عمود `label` للاستخدام الداخلي (لن يُعرض على المستخدم).

#### مثال: مجموع النقاط من إجابات متعددة

| النوع                | الاسم        | عمود calculation      |
| -------------------- | ------------ | --------------------- |
| integer              | q1           |                       |
| integer              | q2           |                       |
| integer              | q3           |                       |
| نوع السؤال calculate | total\_score | ${q1} + ${q2} + ${q3} |

في هذا المثال:

* يجيب المستخدم عن ثلاثة أسئلة رقمية (`q1`, `q2`, `q3`).
* الـ `total_score` يقوم الحقل بجمع تلك القيم الثلاث معًا.
* قيمة `total_score` يتم حفظها في بيانات النموذج، حتى لو لم تُعرض أبداً.

#### دوال حسابية مفيدة

يمكنك استخدام معظم العاملات والدوال القياسية، مثل:

* رياضيات: `+`, `-`, `*`, `div`, `mod`
* نص:  `string-length(), regex, round, substr, concat`
* منطق: `if(condition, true, false)`, `coalesce()`
* التواريخ: `today()`, `now()`, `date()`


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ngsurvey.com/ar/projects/import-export/xlsform/wrqh-alastbyan/alhsabat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
