# Software Metering NQL examples

## Querying the software metering data <a href="#softwaremeteringnqlexamples-queryingthesoftwaremeteringdata" id="softwaremeteringnqlexamples-queryingthesoftwaremeteringdata"></a>

Use Nexthink Query Language (NQL) in the [Investigations](https://docs.nexthink.com/platform/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/investigations) module to access software metering data and other relevant information.

## NQL data structure <a href="#softwaremeteringnqlexamples-nqldatastructure" id="softwaremeteringnqlexamples-nqldatastructure"></a>

The `software_metering.events` table contains software usage data. Each event has a resolution of 1 week. The retention of this data is 90 days.

### Examples of NQL queries <a href="#softwaremeteringnqlexamples-examplesofnqlqueries" id="softwaremeteringnqlexamples-examplesofnqlqueries"></a>

<details>

<summary>Get a list of users underusing the desktop-based software, for example, using it less than two hours in the last 90d.</summary>

{% code lineNumbers="true" %}

```
Users during past 30d
| with software_metering.events during past 90d
| where meter_configuration.name == "*office*"
| compute desktop_app_usage = desktop_focus_time.sum()
| where desktop_app_usage != NULL and desktop_app_usage < 2h
| list user.name, desktop_app_usage
```

{% endcode %}

</details>

<details>

<summary>Get a list of devices with an application package installed but no usage of the application in the last 90d.</summary>

{% code lineNumbers="true" %}

```
Devices during past 30d
| include software_metering.events during past 90d
| where meter_configuration.name  == "visio"
| compute desktop_app_usage = desktop_focus_time.sum()
| include package.installed_packages
| where Package.name == "*visio*"
| where package.type == program
| compute packages_installed = device.count()
| where desktop_app_usage == NULL and packages_installed > 0
| list device.name, desktop_app_usage, packages_installed
```

{% endcode %}

</details>

<details>

<summary>If web usage time is not enabled: get a list of users who have accessed the web-based software at least once.</summary>

{% code lineNumbers="true" %}

```
users during past 30d
| with software_metering.events during past 90d
| where meter_configuration.name == "*miro*"
| where web_is_used == TRUE
| compute event_where_web_was_used = count()
| where event_where_web_was_used > 0
| summarize users_using_application = count()
```

{% endcode %}

</details>
