> 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 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://docs.ngsurvey.com/ar/projects/import-export/xlsform/wrqh-alastbyan/alhsabat.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.
