Is there a way to calculate Azure Savings Plan Benefit with the FlexReport dataset "Azure Cost Management"?
search cancel

Is there a way to calculate Azure Savings Plan Benefit with the FlexReport dataset "Azure Cost Management"?

book

Article ID: 283974

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

Yes, using FlexReport queries.

Here is the sample FlexReport query you can use to calculate the Cost Before Savings Plan, Savings From Savings, and Savings Percentage:

{
  "sqlStatement": "SELECT timeInterval_Month AS Month, SUM(CostInReportingCurrency) AS SUM_CostInReportingCurrency, SUM(Quantity) AS SUM_Quantity, ResourceName AS ResourceName, SubscriptionName AS SubscriptionName, ResourceGroup AS ResourceGroup, MeterName AS MeterName, ResourceLocation AS ResourceLocation, UnitPrice AS UnitPrice, PaygPrice AS PaygPrice, ROUND(UnitPrice * SUM(Quantity), 2) AS CostBeforeSP, ROUND((UnitPrice * SUM(Quantity) - SUM(CostInReportingCurrency)), 2) AS SavingsFromSP, ROUND(((UnitPrice * SUM(Quantity)) - SUM(CostInReportingCurrency)) / (UnitPrice * SUM(Quantity)) * 100, 2) AS Savings_Percentage FROM AZURE_COST_USAGE WHERE (PricingModel IN ('SavingsPlan')) AND (MetricType LIKE '%Amortized%') AND (ConsumedService LIKE '%Microsoft.Compute%') GROUP BY timeInterval_Month, ResourceName, SubscriptionName, ResourceGroup, ResourceLocation, UnitPrice, PaygPrice, MeterName ORDER BY SUM_Quantity DESC",
  "needBackLinkingForTags": true,
  "dataGranularity": "MONTHLY",
  "timeRange": {
    "last": 1,
    "excludeCurrent": true
  },
  "limit": -1
}