Creating reports
1. Navigate to https://reporting-hope-dev.unitst.org/admin/ ⧉
2. Scroll down and click "Queries"
3. Click "ADD QUERY"
4. Click the "Country office" dropdown.
5. Select "Afghanistan".
6. Click the "Name:" field.
7. Type the name of the query e.g "Afghan query for all households"
8. Click the "Target" drop-down menu. It designates the table you will query from the database. In our case, we will use the Household table.
Alert: The list of tables available in the Hope project can be viewed at this link ⧉. Information about relationships between tables can be found in the Django documentation ⧉.
9. Start typing the code for the query. Remember, here conn represents conn=Household.objects
. Please refer to Django ⧉.
10.
result = list(conn.filter(withdrawn=False, first_registration_date__year__gte=2024).values("unicef_id", "admin1__name"))
Here we will query the list of households which are not withdrawn and were registered in 2024 or above. We will only retrieve their unicef_id and Admin1 area name. The query must return data that we must assign to the result variable.
11. We then save and continue editing
12. Click "Queue" to launch the retrieval of the data.
13. If you want to preview the result, click "DATASETS" button.
14. Click on the query "[ABSTRACT] Afghan query for all households"
15. Click "PREVIEW" to see the results. You should see that your query is working correctly.
16. Click on the navigation link "Power Query" so that we can produce the actual report in its format.
17. Click "Add" on the Report Configuration
18. Click this drop-down and choose which country office the report will belong to.
19. Fill in the "Report Title:" field. "Report on Afghan households in 2024"
20. Click the "Query" field.
21. Search for the query you previously created by typing "afgh".
22. Click "[ABSTRACT] Afghan query for all households"
23. Add "Queryset To HTML" if you want to see the report as an html page and file.
24. Add "Dataset to XLSX" if you want to see the report as an Excel file.
25. Click "Choose" and move them on the other side.
26. Save and continue editing.
27. Click "Queue" to generate the actual reports.
28. Click "VIEW ON SITE" in order to view the resulting reports.
29. Click "view"