Question: I'm new to Power BI and struggling to work out the following.In excel i would have used a COUNTIF. I have a table:

```
+-----+----------+
| ID  | Status   |
+-----+----------+
| 1   | Complete |
+-----+----------+
| 2   | Started  |
+-----+----------+
| 3   | Started  |
+-----+----------+
| 1   | Complete |
+-----+----------+
| 1   | Complete |
+-----+----------+

```

I would like to summarize the data and count the number of `complete` jobs, grouped by `ID`. The output i would like is :

```
+-----+----------+-------+
|  ID | Status   | Count |
+-----+----------+-------+
| 1   | Complete | 3     |
+-----+----------+-------+
| 2   | Started  | 1     |
+-----+----------+-------+
| 3   | Started  | 1     |
+-----+----------+-------+
| 1   | Complete | 3     |
+-----+----------+-------+
| 1   | Complete | 3     |
+-----+----------+-------+

```

Which i would then like to keep only distinct values where the count is greater than 2 (is this possible without the intermediate step above? ). So my final desired result is:

```
+-----+----------+-------+
| ID  | Status   | Count |
+-----+----------+-------+
| 1   | Complete | 3     |
+-----+----------+-------+

```

I have tried:

```
 Unique =  COUNTAX(FILTER(Sheet1,(Sheet1[Status] = "Complete" && (Sheet1[Status] = EARLIER(Sheet1[Status])))),Sheet1[Status])

```

but this gives me a running total and not the count.

What formula do i need to use please?

thanks

Answer: 
You will use the dedicated function [`wc_get_order_statuses()`](https://github.com/woocommerce/woocommerce/blob/master/includes/wc-order-functions.php#L86-L104), from WC\_Order functions, which give you by default the following array:

```
$order_statuses = array(
    'wc-pending'    => _x( 'Pending payment', 'Order status', 'woocommerce' ),
    'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
    'wc-on-hold'    => _x( 'On hold', 'Order status', 'woocommerce' ),
    'wc-completed'  => _x( 'Completed', 'Order status', 'woocommerce' ),
    'wc-cancelled'  => _x( 'Cancelled', 'Order status', 'woocommerce' ),
    'wc-refunded'   => _x( 'Refunded', 'Order status', 'woocommerce' ),
    'wc-failed'     => _x( 'Failed', 'Order status', 'woocommerce' ),
);

```

> 
> All **custom additional order statuses will be included too** as the filter hook `wc_order_statuses` is applied inside this function.
> 
> 
>
Add below snippet to functions.php and call woocommerce\_get\_order\_statuses() where you want to use. 

```
function woocommerce_get_order_statuses() {
      $order_statuses = get_terms( 'shop_order_status', array( 'hide_empty' => false ) );
      $statuses = array();
      foreach ( $order_statuses as $status ) {
        $statuses[ $status->slug ] = $status->name;
      }
      return $statuses;
    }

```