> For the complete documentation index, see [llms.txt](https://enterprise-docs.datacamp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enterprise-docs.datacamp.com/integrating-our-data-into-your-tools-via-data-connector-2.0/queries-to-recreate-key-reports-in-the-groups-tab/dashboard/members-who-have-earned-xp.md).

# Members who have earned XP

<figure><img src="/files/LBBc0kB4pd4M5hjKBJYS" alt=""><figcaption></figcaption></figure>

To get the number of members who have earned XP, you can use the following query:

```sql
SELECT
  count(DISTINCT user_id) AS total_members
FROM data_connector_1234.fact_learn_events
WHERE event_name IN ('assessment_engaged', 
                    'course_engagement', 
                    'practice_engagement', 
                    'project_engagement', 
                    'b2b_onboarding_xp_boost', 
                    'alpa_onboarding')
  AND xp_earned > 0
```

The number below with the arrow is the number of new members in the last 30 days. You can calculate it by getting the number of members up until last month and subtracting it from the all-time total calculated above.

```sql
SELECT
  count(DISTINCT user_id) AS total_members
FROM data_connector_1234.fact_learn_events
WHERE event_name IN ('assessment_engaged', 
                    'course_engagement', 
                    'practice_engagement', 
                    'project_engagement', 
                    'b2b_onboarding_xp_boost', 
                    'alpa_onboarding')
  AND xp_earned > 0
  -- members last month
  AND date(occurred_at) <= date_add('day', -31, current_date)
```

{% hint style="warning" %}
In the queries above, we specify the XP events to include. This is to avoid double counting XP in courses since the dataset contains `course_engagement` and `exercise_completed` events with a non-zero `xp_earned` value. Both contain XP gained from completing an exercise, so including both would lead to double counting XP earned in courses.

Please check the [Domain Gotchas](/integrating-our-data-into-your-tools-via-data-connector-2.0/domain-gotchas.md) section for more details.
{% endhint %}


---

# 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:

```
GET https://enterprise-docs.datacamp.com/integrating-our-data-into-your-tools-via-data-connector-2.0/queries-to-recreate-key-reports-in-the-groups-tab/dashboard/members-who-have-earned-xp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
