# GCP BigQuery Expression | Monthly Invoice Based on Labels

In this GCP BigQuery expression, I show how you can retrieve the monthly invoice data on all resources in a specified project based on assigned label values. This method of capturing cloud spend can be applied after you've enabled the [Cloud Billing data export to BigQuery](https://cloud.google.com/billing/docs/how-to/export-data-bigquery) functionality.

This query performs the following functions:

* The sum of regular costs, taxes, adjustments and rounding errors for each invoice month using inner CAST
    
* The CROSS JOIN statement excludes Null arrays/rows and UNNEST operator flattens the array of labels into rows
    
* Filter by project name
    
* Group by key/value labels and invoice month
    
* Order by invoice month
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678737413340/05d5abdb-9eec-4719-9226-4588e4c1a99c.png align="center")

This is just one scenario displaying the value of applying tags/labels on your cloud resources. I've found tagging essential when it comes to cloud cost analysis, especially across a multi-cloud, multi-platform infrastructure!

Link to query on Gist: [https://gist.github.com/jksprattler/80519ade571714c4415e103ccc8ad2be](https://gist.github.com/jksprattler/80519ade571714c4415e103ccc8ad2be)
