> ## Documentation Index
> Fetch the complete documentation index at: https://docs.junction.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Prioritization

> Learn how Junction Sense automatically prioritizes data from multiple providers and source types, keeping only the highest-priority source per group.

## Overview

Data prioritization automatically kicks in whenever you use a [Group By clause](/sense/query-dsl/group-by-clause).

Within each group outlined by your [Group By clause](/sense/query-dsl/group-by-clause), the query executor would **implicitly**:

* Sub-group the data further by their Provider and their [Source Type](/wearables/providers/data-attributions);
* Keep only data from the sub-group that has the highest Source Type priority, or the highest Provider priority when multiple sub-groups exist
  for the same Source Type.

<Note>
  Data prioritization works only in a [Group By](/sense/query-dsl/group-by-clause) context.
</Note>

<Note>
  If both the *Provider* and *Source Type* Source Columns are present in the [Group By clause](/sense/query-dsl/group-by-clause),
  the implicit [Data Prioritization](/sense/data-prioritization) behavior would be disabled.
</Note>

<Accordion title="Example" defaultOpen>
  You are querying Sleep Score grouped by every 1 day:

  ```json theme={null}
  {
      "select": [
          { "func": "newest", "arg": { "value_macro": "sleep_score" } }
      ],
      "group_by": [
          { "date_trunc": { "value": 1, "unit": "day" }, "arg": { "index": "sleep" } }
      ]
  }
  ```

  Assuming this timeline:

  * Day 1: The user connected Oura.
  * Day 5: The user connected Apple HealthKit.
  * Both Oura and HealthKit have been consistently sending sleep data every day since connected.

  #### If your team priority states that Apple HealthKit > Oura

  The query result would be:

  * Day 1-4: Sleep Score computed from Oura sleep data
  * Day 5-7: Sleep Score computed from Apple HealthKit sleep data

  #### If your team priority states that Oura > Apple HealthKit

  The query result would be:

  * Day 1-7: Sleep Score computed from Oura sleep data

  <Info>
    Apple HealthKit data are ignored in this case, because Oura is available throughout all
    days and has higher provider priority.
  </Info>
</Accordion>

## Previewing the prioritization effect

You can experiment and preview the effect of prioritization using the [Query API](/sense/using-query-api).

By specifying a list of provider slugs in `config.provider_priority_overrides`, you instruct the query executor to treat these providers
as the highest priority — above the team provider priority — specifically in this query invocation.

## Managing Provider Priorities

You can manage the provider priorities for each summary type through the **Data Priority** section of the [Junction Dashboard](https://app.junction.com/).

<Note>A larger number indicates a higher priority.</Note>

## Source Type Priorities

We use pre-assigned, non-configurable Source Type priorities that follow the general expectation of data reliability.

*(sorted from highest priority to lowest priority)*

* `lab`
* `automatic`
* `watch`
* `ring`
* `chest_strap`
* `scale`
* `cuff`
* `fingerprick`
* `manual_scan`
* `phone`
* `app`
* `multiple_sources`
* `unknown`
