How can I apply an expression to query results in Grafana?

Hi ,
I’m working on a dashboard in Grafana where I have two queries (A and B). I want to perform a mathematical operation using an Expression (C) to combine the results of both queries.

My setup:

  • Query A → Retrieves the total cost (Sum costs.unblended_cost).
  • Query B → Retrieves the Top 10 services by cost, grouped by line_item.product_code.
  • Expression C → Trying to apply a formula like $A + $B or $B / $A * 100.

What I need help with:

:white_check_mark: How can I apply an expression that correctly references query results?
:white_check_mark: What is the best approach to ensure queries return a single value when needed?
:white_check_mark: Is there a recommended way to combine multiple queries before applying an expression?

I’m open to any suggestions or best practices! Thanks in advance for your help.