chris-bowman/Azure-Cost-Reporting

How to specify Tags for Cost Allocations report

HumanSolutions opened this issue · 2 comments

Thanks for sharing this tool. I have found it very useful. I have 7 tags. Is there a way to list and report on them in Cost allocations tab? thanks again.

Hi @HumanSolutions,
The sample report has a couple of example extractions for the Tags field, you will find Tags.CostCentre and Tags.Application in the Resources table, which are fairly common. You can copy the DAX and make a new column, substituting the LookupKey for the tag you are searching for. You can then add these into the Cost Allocations tab for your 7 tags.

I did previously parse the JSON in the Power Query during import, but found it ended up erroring or timing out more often than not due to the sheer volume of tags and free-form in the deployments, so instead extracted only what is necessary for the report.

Example if you had a tag called "Environment":

Tags.Environment = 
VAR LookupKey = "Environment"
VAR SearchField = Resources[Tags]
VAR FindLookupKey = SEARCH(LookupKey,SearchField,1,1)
VAR FindValueStartColon = SEARCH(":",SearchField,FindLookupKey,1)+2 
VAR FindValueStart = IF(MID(SearchField,FindValueStartColon,1)="""",FindValueStartColon+1)
VAR FindValueEnd = SEARCH(",",SearchField,FindLookupKey,LEN(SearchField)+1)-FindValueStartColon-2

RETURN TRIM(iferror(if(FindLookupKey>1, MID(SearchField,FindValueStart,FindValueEnd),""),""))

this worked!! thank you for the resolution.