Power BI Reports for Azure Lab Services - Part 1: Visualizing Cost Management Data

Published Aug 18 2021 09:00 AM 1,351 Views
Microsoft

Azure Lab Services costs are integrated with Cost Management on the lab account level.  However, sometimes it’s useful to create a custom report for your team.  We can do this using the line item data from Cost Management.  In this blog post we will use Power BI desktop to create a basic report that shows total cost, total number of virtual machines and total number of labs.  The report will also include a table that shows cost per lab and cost per virtual machine.

 

planetmaher_0-1629153655517.png

 

To create this report, we need to complete four major tasks.

  1. Get the data. We need to import data into PowerBI.
  2. Transform the data.   Each cost line item has all the information we need, but it will need to be separated, so we can work with lab and lab virtual machine information individually.
  3. Create the data visualization.
  4. Publish the report for others to see.

Get the data

There are couple options to import the Cost Management data into PowerBI.  Which one to use will depend on your type of Azure agreement and your permission level.

 

Azure Cost Management connector

The first option is the Azure Cost Management connector. Follow the instructions at Create visuals and reports with the Azure Cost Management connector in Power BI Desktop.  You will need to provide a billing scope which could cover from a billing agreement to a specific resource group.  See understand and work with Azure Cost Management scopes for more information about scopes.  See identify resource id for a scope for instructions to get billing scope based on the type of scope you are using.

 

The Azure Cost Management connector currently supports customers with a Microsoft Customer Agreement or an Enterprise Agreement (EA).  There are also some unsupported subscription types.  To successfully use the connector, you must have correct permissions and the ability for users to read cost management data must be enabled by the tenant administrator.  You can check your access by calling the cost management usage detail api directly.

 

Azure Cost Management exports

The second option is to export costs to a storage account fromAzure Cost Management.  Follow instructions at Tutorial - Create and manage exported data from Azure Cost Management | Microsoft Docs to create the recurring export.  You can choose to have data exported daily, weekly or monthly.  Each export will be a CSV file saved in blob storage.

 

In PowerBI Desktop, we will use the Azure Blob Storage connector to import this data.  Select the usage detail data from the storage account container you used when scheduling the cost management data exports.  Choose to combine the files when importing the CSV file data.

 

Transform the data

Each usage detail line item has the information for the full resource id of the virtual machine (either template or student) associated with the cost.  As explained in cost management guide for Azure Lab Services, these resources will follow one of two patterns. 

For templates virtual machines:

/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.LabServices/labaccounts/{lab-account-name}/environmentsettings/default

For student virtual machines:

/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.LabServices/labaccounts/{lab-account-name}/environmentsettings/default/environments/{vm-name}

For our report, we will need to extract the required data the from the InstanceId property of the Cost Management usage details.  Complete the following steps in Power Query.

  1. Filter on ConsumedService equal to microsoft.labservices
  2. Remove duplicate rows.  We do this to avoid any issues if using Cost Management exports and data is accidentally exported multiple times.  Select all columns except the Source.Name.
  3. Duplicate InstanceId column and rename it ResourceId.
  4. Split the InstanceId column on the ‘/’ character.
  5. Clean up split columns.
    1. Delete InstanceId.1 to InstanceId.8.  We already have the SubscriptionGuid and ResourceGroup columns, so the InstanceId.3 and InstanceId.5 columns aren’t needed. 
    2. Rename InstanceId.9 to LabAccount.
    3. Delete InstanceId.10.
    4. Rename InstanceId.11 to Lab.
    5. Delete InstanceId.12 to InstanceId.14.
    6. Rename InstanceId.15 to VirtualMachine.
    7. Replace ‘null’ values with ‘template’.  Any rows that don’t have a value for VirtualMachine are costs associated with running the template virtual machine for the lab.
  6. Save transformations.

Schema for the table should look something like the picture below.  Depending on your Azure subscription type, there may be more columns not seen in this example.

planetmaher_1-1629153655523.png

 

Visualize the data

First, let’s create some cards for high-level information.  Our cards will show the total cost, number of labs and number of virtual machines used. 

 

Total Cost

The total cost is held in the PreTaxCost column.  PowerBI already recognizes that PreTaxCost is number and will automatically add all the column values to create a sum.  Add a card to the visual and add PreTaxCost to the Field property of the card visualization.  Optionally change the name for the visualization from PreTaxCost to Total Cost.  

 

planetmaher_2-1629153655529.png

Number of Labs

Next, let’s display the number labs.  We’ll need to create a new measure for this.  For instructions explaining how to create a new measure, see create your own measures in Power BI Desktop tutorial

 

For the most accurate reporting, we can’t just create a measure that counts all the distinct values in the Lab column because it is possible to have two labs with the same name in different lab accounts.  So, for our measure named NumberOfLabs we will count the number of rows when grouped by all the identifying columns for a lab, which are subscription, resource group, lab account and lab name.  Note, in this example the table name is dailyexports.

NumberOfLabs = COUNTROWS(GROUPBY(dailyexports, dailyexports[SubscriptionGuid], dailyexports[ResourceGroup], dailyexports[LabAccount], dailyexports[Lab]))

Now we can create a card for the NumberOfLabs measure by following instructions at create card visualizations (big number tiles).

 

Total Number of Virtual Machines

Creating a card for the total number of virtual machines used will be similar to creating a card for total number of labs.  We need to create a measure that counts the unique combination of subscription, resource group, lab account, lab and virtual machine name.  Our new measure is

NumberOfVMs = COUNTROWS(GROUPBY(dailyexports, dailyexports[SubscriptionGuid], dailyexports[ResourceGroup], dailyexports[LabAccount], dailyexports[Lab], dailyexports[VirtualMachine]))

Now we can create a card for NumberOfVMs measure by following instructions at create card visualizations (big number tiles) .

 

Matrix

Now let’s create a matrix visual to allow us to drill down into our data. For instructions how to create a matrix visualization, see create a matrix visual in Power BI.  For our matrix visualization, we’ll add the Subscription, ResourceGroup, Lab Account, Lab, VirtualMachine for the rows.  NumberOfLabs, NumberOfVMs, PreTaxCost and Currency will be our values.  Note, for the currency column, the first value for currency will be shown with the matrix is collapsed.

 

After of renaming the columns for the visuals and applying some theming, our report now looks like the following picture.  I’ve expanded the subscription, resource groups and the ‘enewman-demo’ lab account.  Under the lab account you can see the two labs and total cost for each lab.  As you can see by the plus sign next to the lab’s names, each lab could be expanded to list the virtual machines for the lab as well as the cost for each virtual machine.

 

planetmaher_3-1629153655531.png

Publish the data

Last step is to publish the report!  See publish datasets and reports from Power BI Desktop for further instructions.

 

Happing Reporting!

The Lab Services Team

%3CLINGO-SUB%20id%3D%22lingo-sub-2654238%22%20slang%3D%22en-US%22%3EPower%20BI%20Reports%20for%20Azure%20Lab%20Services%20-%20Part%201%3A%20Visualizing%20Cost%20Management%20Data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2654238%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20Lab%20Services%20costs%20are%20integrated%20with%20Cost%20Management%20on%20the%20lab%20account%20level.%26nbsp%3B%20However%2C%20sometimes%20it%E2%80%99s%20useful%20to%20create%20a%20custom%20report%20for%20your%20team.%26nbsp%3B%20We%20can%20do%20this%20using%20the%20line%20item%20data%20from%20Cost%20Management.%26nbsp%3B%20In%20this%20blog%20post%20we%20will%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpower-bi%2Ffundamentals%2Fdesktop-what-is-desktop%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPower%20BI%20desktop%3C%2FA%3E%20to%20create%20a%20basic%20report%20that%20shows%20total%20cost%2C%20total%20number%20of%20virtual%20machines%20and%20total%20number%20of%20labs.%26nbsp%3B%20The%20report%20will%20also%20include%20a%20table%20that%20shows%20cost%20per%20lab%20and%20cost%20per%20virtual%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22planetmaher_0-1629153655517.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303626iC12C843897FF6944%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22planetmaher_0-1629153655517.png%22%20alt%3D%22planetmaher_0-1629153655517.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20create%20this%20report%2C%20we%20need%20to%20complete%20four%20major%20tasks.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EGet%20the%20data.%20We%20need%20to%20import%20data%20into%20PowerBI.%3C%2FLI%3E%0A%3CLI%3ETransform%20the%20data.%26nbsp%3B%20%26nbsp%3BEach%20cost%20line%20item%20has%20all%20the%20information%20we%20need%2C%20but%20it%20will%20need%20to%20be%20separated%2C%20so%20we%20can%20work%20with%20lab%20and%20lab%20virtual%20machine%20information%20individually.%3C%2FLI%3E%0A%3CLI%3ECreate%20the%20data%20visualization.%3C%2FLI%3E%0A%3CLI%3EPublish%20the%20report%20for%20others%20to%20see.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH1%20id%3D%22toc-hId-1415873203%22%20id%3D%22toc-hId-1416711131%22%3EGet%20the%20data%3C%2FH1%3E%0A%3CP%3EThere%20are%20couple%20options%20to%20import%20the%20Cost%20Management%20data%20into%20PowerBI.%26nbsp%3B%20Which%20one%20to%20use%20will%20depend%20on%20your%20type%20of%20Azure%20agreement%20and%20your%20permission%20level.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2106434677%22%20id%3D%22toc-hId-2107272605%22%3EAzure%20Cost%20Management%20connector%3C%2FH2%3E%0A%3CP%3EThe%20first%20option%20is%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fconnect-data%2Fdesktop-connect-azure-cost-management%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Cost%20Management%20connector%3C%2FA%3E.%20Follow%20the%20instructions%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpower-bi%2Fconnect-data%2Fdesktop-connect-azure-cost-management%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20visuals%20and%20reports%20with%20the%20Azure%20Cost%20Management%20connector%20in%20Power%20BI%20Desktop%3C%2FA%3E.%26nbsp%3B%20You%20will%20need%20to%20provide%20a%20billing%20scope%20which%20could%20cover%20from%20a%20billing%20agreement%20to%20a%20specific%20resource%20group.%26nbsp%3B%20See%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcost-management-billing%2Fcosts%2Funderstand-work-scopes%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eunderstand%20and%20work%20with%20Azure%20Cost%20Management%20scopes%3C%2FA%3E%20for%20more%20information%20about%20scopes.%26nbsp%3B%20See%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcost-management-billing%2Fcosts%2Funderstand-work-scopes%23identify-the-resource-id-for-a-scope%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eidentify%20resource%20id%20for%20a%20scope%3C%2FA%3E%20for%20instructions%20to%20get%20billing%20scope%20based%20on%20the%20type%20of%20scope%20you%20are%20using.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Azure%20Cost%20Management%20connector%20currently%20supports%20customers%20with%20a%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fpricing%2Fpurchase-options%2Fmicrosoft-customer-agreement%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Customer%20Agreement%3C%2FA%3E%26nbsp%3Bor%20an%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fpricing%2Fenterprise-agreement%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EEnterprise%20Agreement%20(EA)%3C%2FA%3E.%26nbsp%3B%20There%20are%20also%20some%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Frest%2Fapi%2Fconsumption%2F%23list-of-unsupported-subscription-types%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eunsupported%20subscription%20types%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%20%26nbsp%3BTo%20successfully%20use%20the%20connector%2C%20you%20must%20have%20correct%20permissions%20and%20the%20ability%20for%20users%20to%20read%20cost%20management%20data%20must%20be%20enabled%20by%20the%20tenant%20administrator.%26nbsp%3B%20You%20can%20check%20your%20access%20by%20calling%20the%20cost%20management%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Frest%2Fapi%2Fconsumption%2Fusage-details%2Flist%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eusage%20detail%20api%3C%2FA%3E%20directly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-298980214%22%20id%3D%22toc-hId-299818142%22%3EAzure%20Cost%20Management%20exports%3C%2FH2%3E%0A%3CP%3EThe%20second%20option%20is%20to%20export%20costs%20to%20a%20storage%20account%20fromAzure%20Cost%20Management.%26nbsp%3B%20Follow%20instructions%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcost-management-billing%2Fcosts%2Ftutorial-export-acm-data%3Ftabs%3Dazure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETutorial%20-%20Create%20and%20manage%20exported%20data%20from%20Azure%20Cost%20Management%20%7C%20Microsoft%20Docs%3C%2FA%3E%20to%20create%20the%20recurring%20export.%26nbsp%3B%20You%20can%20choose%20to%20have%20data%20exported%20daily%2C%20weekly%20or%20monthly.%26nbsp%3B%20Each%20export%20will%20be%20a%20CSV%20file%20saved%20in%20blob%20storage.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20PowerBI%20Desktop%2C%20we%20will%20use%20the%20Azure%20Blob%20Storage%20connector%20to%20import%20this%20data.%26nbsp%3B%20Select%20the%20usage%20detail%20data%20from%20the%20storage%20account%20container%20you%20used%20when%20scheduling%20the%20cost%20management%20data%20exports.%26nbsp%3B%20Choose%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Ftransform-model%2Fdesktop-combine-binaries%23combine-files-behavior%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecombine%20the%20files%3C%2FA%3E%20when%20importing%20the%20CSV%20file%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-288477110%22%20id%3D%22toc-hId-289315038%22%3ETransform%20the%20data%3C%2FH1%3E%0A%3CP%3EEach%20usage%20detail%20line%20item%20has%20the%20information%20for%20the%20full%20resource%20id%20of%20the%20virtual%20machine%20(either%20template%20or%20student)%20associated%20with%20the%20cost.%26nbsp%3B%20As%20explained%20in%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Flab-services%2Fcost-management-guide%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ecost%20management%20guide%20for%20Azure%20Lab%20Services%3C%2FA%3E%2C%20these%20resources%20will%20follow%20one%20of%20two%20patterns.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20templates%20virtual%20machines%3A%3C%2FP%3E%0A%3CPRE%3E%2Fsubscriptions%2F%7Bsubscription-id%7D%2FresourceGroups%2F%7Bresource-group%7D%2Fproviders%2FMicrosoft.LabServices%2Flabaccounts%2F%7Blab-account-name%7D%2Fenvironmentsettings%2Fdefault%3C%2FPRE%3E%0A%3CP%3EFor%20student%20virtual%20machines%3A%3C%2FP%3E%0A%3CPRE%3E%2Fsubscriptions%2F%7Bsubscription-id%7D%2FresourceGroups%2F%7Bresource-group%7D%2Fproviders%2FMicrosoft.LabServices%2Flabaccounts%2F%7Blab-account-name%7D%2Fenvironmentsettings%2Fdefault%2Fenvironments%2F%7Bvm-name%7D%3C%2FPRE%3E%0A%3CP%3EFor%20our%20report%2C%20we%20will%20need%20to%20extract%20the%20required%20data%20the%20from%20the%20%3CSTRONG%3EInstanceId%3C%2FSTRONG%3E%26nbsp%3Bproperty%20of%20the%20Cost%20Management%20usage%20details.%26nbsp%3B%20Complete%20the%20following%20steps%20in%20Power%20Query.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EFilter%20on%20%3CSTRONG%3EConsumedService%3C%2FSTRONG%3E%20equal%20to%20%3CSTRONG%3Emicrosoft.labservices%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-query%2Fworking-with-duplicates%23remove-duplicates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ERemove%20duplicate%20rows%3C%2FA%3E.%26nbsp%3B%20We%20do%20this%20to%20avoid%20any%20issues%20if%20using%20Cost%20Management%20exports%20and%20data%20is%20accidentally%20exported%20multiple%20times.%26nbsp%3B%20%3CEM%3ESelect%20all%20columns%20except%20the%20%3CSTRONG%3ESource.Name%3C%2FSTRONG%3E.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3EDuplicate%20%3CSTRONG%3EInstanceId%3C%2FSTRONG%3E%26nbsp%3Bcolumn%20and%20rename%20it%20%3CSTRONG%3EResourceId.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-query%2Fsplit-columns-delimiter%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESplit%3C%2FA%3E%20the%20%3CSTRONG%3EInstanceId%3C%2FSTRONG%3E%26nbsp%3Bcolumn%20on%20the%20%E2%80%98%2F%E2%80%99%20character.%3C%2FLI%3E%0A%3CLI%3EClean%20up%20split%20columns.%3COL%20start%3D%228%22%3E%0A%3CLI%3EDelete%20%3CSTRONG%3EInstanceId.1%3C%2FSTRONG%3E%20to%20%3CSTRONG%3EInstanceId.8%3C%2FSTRONG%3E.%26nbsp%3B%20We%20already%20have%20the%20%3CSTRONG%3ESubscriptionGuid%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EResourceGroup%3C%2FSTRONG%3E%20columns%2C%20so%20the%20%3CSTRONG%3EInstanceId.3%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EInstanceId.5%3C%2FSTRONG%3E%20columns%20aren%E2%80%99t%20needed.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3ERename%20%3CSTRONG%3EInstanceId.9%3C%2FSTRONG%3E%20to%20%3CSTRONG%3ELabAccount%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3EDelete%20%3CSTRONG%3EInstanceId.10%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3ERename%20%3CSTRONG%3EInstanceId.11%3C%2FSTRONG%3E%20to%20%3CSTRONG%3ELab%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3EDelete%20%3CSTRONG%3EInstanceId.12%3C%2FSTRONG%3E%20to%20%3CSTRONG%3EInstanceId.14%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3ERename%20%3CSTRONG%3EInstanceId.15%3C%2FSTRONG%3E%20to%20%3CSTRONG%3EVirtualMachine%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-query%2Freplace-values%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EReplace%3C%2FA%3E%20%E2%80%98null%E2%80%99%20values%20with%20%E2%80%98template%E2%80%99.%26nbsp%3B%20Any%20rows%20that%20don%E2%80%99t%20have%20a%20value%20for%20%3CSTRONG%3EVirtualMachine%3C%2FSTRONG%3E%20are%20costs%20associated%20with%20running%20the%20template%20virtual%20machine%20for%20the%20lab.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3ESave%20transformations.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ESchema%20for%20the%20table%20should%20look%20something%20like%20the%20picture%20below.%26nbsp%3B%20Depending%20on%20your%20Azure%20subscription%20type%2C%20there%20may%20be%20more%20columns%20not%20seen%20in%20this%20example.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22planetmaher_1-1629153655523.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303627i39A12AA75C6093AE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22planetmaher_1-1629153655523.png%22%20alt%3D%22planetmaher_1-1629153655523.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1518977353%22%20id%3D%22toc-hId--1518139425%22%3EVisualize%20the%20data%3C%2FH1%3E%0A%3CP%3EFirst%2C%20let%E2%80%99s%20create%20some%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fvisuals%2Fpower-bi-visualization-card%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecards%3C%2FA%3E%20for%20high-level%20information.%26nbsp%3B%20Our%20cards%20will%20show%20the%20total%20cost%2C%20number%20of%20labs%20and%20number%20of%20virtual%20machines%20used.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1669600058%22%20id%3D%22toc-hId-1670437986%22%3ETotal%20Cost%3C%2FH3%3E%0A%3CP%3EThe%20total%20cost%20is%20held%20in%20the%20%3CSTRONG%3EPreTaxCost%3C%2FSTRONG%3E%20column.%26nbsp%3B%20PowerBI%20already%20recognizes%20that%20PreTaxCost%20is%20number%20and%20will%20automatically%20add%20all%20the%20column%20values%20to%20create%20a%20sum.%26nbsp%3B%20Add%20a%20card%20to%20the%20visual%20and%20add%20%3CSTRONG%3EPreTaxCost%3C%2FSTRONG%3E%20to%20the%20%3CSTRONG%3EField%3C%2FSTRONG%3E%20property%20of%20the%20card%20visualization.%26nbsp%3B%20Optionally%20change%20the%20name%20for%20the%20visualization%20from%20%3CSTRONG%3EPreTaxCost%3C%2FSTRONG%3E%20to%20%3CSTRONG%3ETotal%20Cost%3C%2FSTRONG%3E.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22planetmaher_2-1629153655529.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303628i7F6EDCB5B77A0BC0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22planetmaher_2-1629153655529.png%22%20alt%3D%22planetmaher_2-1629153655529.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--137854405%22%20id%3D%22toc-hId--137016477%22%3ENumber%20of%20Labs%3C%2FH3%3E%0A%3CP%3ENext%2C%20let%E2%80%99s%20display%20the%20number%20labs.%26nbsp%3B%20We%E2%80%99ll%20need%20to%20create%20a%20new%20measure%20for%20this.%26nbsp%3B%20For%20instructions%20explaining%20how%20to%20create%20a%20new%20measure%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Ftransform-model%2Fdesktop-tutorial-create-measures%23create-a-measure%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20your%20own%20measures%20in%20Power%20BI%20Desktop%20tutorial%3C%2FA%3E.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20the%20most%20accurate%20reporting%2C%20we%20can%E2%80%99t%20just%20create%20a%20measure%20that%20counts%20all%20the%20distinct%20values%20in%20the%20%3CSTRONG%3ELab%3C%2FSTRONG%3E%20column%20because%20it%20is%20possible%20to%20have%20two%20labs%20with%20the%20same%20name%20in%20different%20lab%20accounts.%26nbsp%3B%20So%2C%20for%20our%20measure%20named%20%3CSTRONG%3ENumberOfLabs%3C%2FSTRONG%3E%20we%20will%20count%20the%20number%20of%20rows%20when%20grouped%20by%20all%20the%20identifying%20columns%20for%20a%20lab%2C%20which%20are%20subscription%2C%20resource%20group%2C%20lab%20account%20and%20lab%20name.%26nbsp%3B%20Note%2C%20in%20this%20example%20the%20table%20name%20is%20%3CSTRONG%3Edailyexports%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CPRE%3ENumberOfLabs%20%3D%20COUNTROWS(GROUPBY(dailyexports%2C%20dailyexports%5BSubscriptionGuid%5D%2C%20dailyexports%5BResourceGroup%5D%2C%20dailyexports%5BLabAccount%5D%2C%20dailyexports%5BLab%5D))%3C%2FPRE%3E%0A%3CP%3ENow%20we%20can%20create%20a%20card%20for%20the%20NumberOfLabs%20measure%20by%20following%20instructions%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fvisuals%2Fpower-bi-visualization-card%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20card%20visualizations%20(big%20number%20tiles)%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1945308868%22%20id%3D%22toc-hId--1944470940%22%3ETotal%20Number%20of%20Virtual%20Machines%3C%2FH3%3E%0A%3CP%3ECreating%20a%20card%20for%20the%20total%20number%20of%20virtual%20machines%20used%20will%20be%20similar%20to%20creating%20a%20card%20for%20total%20number%20of%20labs.%26nbsp%3B%20We%20need%20to%20create%20a%20measure%20that%20counts%20the%20unique%20combination%20of%20subscription%2C%20resource%20group%2C%20lab%20account%2C%20lab%20and%20virtual%20machine%20name.%26nbsp%3B%20Our%20new%20measure%20is%3C%2FP%3E%0A%3CPRE%3ENumberOfVMs%20%3D%20COUNTROWS(GROUPBY(dailyexports%2C%20dailyexports%5BSubscriptionGuid%5D%2C%20dailyexports%5BResourceGroup%5D%2C%20dailyexports%5BLabAccount%5D%2C%20dailyexports%5BLab%5D%2C%20dailyexports%5BVirtualMachine%5D))%3C%2FPRE%3E%0A%3CP%3ENow%20we%20can%20create%20a%20card%20for%20NumberOfVMs%20measure%20by%20following%20instructions%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fvisuals%2Fpower-bi-visualization-card%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20card%20visualizations%20(big%20number%20tiles)%20%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-542203965%22%20id%3D%22toc-hId-543041893%22%3EMatrix%3C%2FH3%3E%0A%3CP%3ENow%20let%E2%80%99s%20create%20a%20matrix%20visual%20to%20allow%20us%20to%20drill%20down%20into%20our%20data.%20For%20instructions%20how%20to%20create%20a%20matrix%20visualization%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fvisuals%2Fdesktop-matrix-visual%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20a%20matrix%20visual%20in%20Power%20BI%3C%2FA%3E.%26nbsp%3B%20For%20our%20matrix%20visualization%2C%20we%E2%80%99ll%20add%20the%3CSTRONG%3E%20Subscription%3C%2FSTRONG%3E%2C%20%3CSTRONG%3EResourceGroup%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ELab%3C%2FSTRONG%3E%20%3CSTRONG%3EAccount%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ELab%3C%2FSTRONG%3E%2C%20%3CSTRONG%3EVirtualMachine%3C%2FSTRONG%3E%20for%20the%20rows.%26nbsp%3B%20%3CSTRONG%3ENumberOfLabs%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ENumberOfVMs%3C%2FSTRONG%3E%2C%20%3CSTRONG%3EPreTaxCost%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ECurrency%3C%2FSTRONG%3E%20will%20be%20our%20values.%26nbsp%3B%20Note%2C%20for%20the%20currency%20column%2C%20the%20first%20value%20for%20currency%20will%20be%20shown%20with%20the%20matrix%20is%20collapsed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20of%20renaming%20the%20columns%20for%20the%20visuals%20and%20applying%20some%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fcreate-reports%2Fdesktop-report-themes%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Etheming%3C%2FA%3E%2C%20our%20report%20now%20looks%20like%20the%20following%20picture.%26nbsp%3B%20I%E2%80%99ve%20expanded%20the%20subscription%2C%20resource%20groups%20and%20the%20%E2%80%98enewman-demo%E2%80%99%20lab%20account.%26nbsp%3B%20Under%20the%20lab%20account%20you%20can%20see%20the%20two%20labs%20and%20total%20cost%20for%20each%20lab.%26nbsp%3B%20As%20you%20can%20see%20by%20the%20plus%20sign%20next%20to%20the%20lab%E2%80%99s%20names%2C%20each%20lab%20could%20be%20expanded%20to%20list%20the%20virtual%20machines%20for%20the%20lab%20as%20well%20as%20the%20cost%20for%20each%20virtual%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22planetmaher_3-1629153655531.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303629i2720A874786F3FD9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22planetmaher_3-1629153655531.png%22%20alt%3D%22planetmaher_3-1629153655531.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1966315076%22%20id%3D%22toc-hId--1965477148%22%3EPublish%20the%20data%3C%2FH1%3E%0A%3CP%3ELast%20step%20is%20to%20publish%20the%20report!%26nbsp%3B%20See%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-bi%2Fcreate-reports%2Fdesktop-upload-desktop-files%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Epublish%20datasets%20and%20reports%20from%20Power%20BI%20Desktop%3C%2FA%3E%20for%20further%20instructions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHapping%20Reporting!%3C%2FP%3E%0A%3CP%3EThe%20Lab%20Services%20Team%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2654238%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20Lab%20Services%20costs%20are%20integrated%20with%20Cost%20Management%20on%20the%20lab%20account%20level.%26nbsp%3B%20We%20can%20also%20create%20a%20custom%20report%20using%20the%20line-item%20data%20from%20cost%20management.%26nbsp%3B%20In%20this%20blog%20post%2C%20we%20will%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpower-bi%2Ffundamentals%2Fdesktop-what-is-desktop%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPower%20BI%20desktop%3C%2FA%3E%20to%20create%20a%20basic%20report%20that%20shows%20total%20cost%2C%20total%20number%20of%20virtual%20machines%20and%20total%20number%20of%20labs.%26nbsp%3B%20The%20report%20will%20also%20include%20a%20table%20that%20shows%20cost%20per%20lab%20and%20cost%20per%20virtual%20machine.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2654238%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELab%20Services%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Aug 17 2021 03:41 PM
Updated by: