I have following query in kusto language:
AzureActivity
| where ResourceProvider == "Microsoft.Compute"
| where OperationName in ('Deallocate Virtual Machine','Start Virtual Machine')
| where ActivityStatus == 'Succeeded'
| order by Resource asc, EventSubmissionTimestamp asc
| extend IsSameResource = (prev(Resource) == Resource)
| extend PrevState = iif(IsSameResource, prev(OperationName), OperationName), CurrentState = OperationName
| extend RunTime = iif(PrevState == 'Start Virtual Machine' and CurrentState == 'Deallocate Virtual Machine', EventSubmissionTimestamp - prev(EventSubmissionTimestamp), time(null)), StartTime = prev(EventSubmissionTimestamp)
| where isnotnull(RunTime)
| project Resource, StartDate= format_datetime(todatetime(StartTime), 'MM/yyyy'), StopDate=format_datetime(todatetime(EventSubmissionTimestamp), 'MM/yyyy'),
RuntimeThisMonth= iif( format_datetime(todatetime(StartTime), 'MM/yyyy') != format_datetime(todatetime(EventSubmissionTimestamp), 'MM/yyyy') , (datetime_diff('minute',todatetime(EventSubmissionTimestamp) ,startofmonth(EventSubmissionTimestamp)) / 60) ,(datetime_diff('minute',todatetime(EventSubmissionTimestamp) ,todatetime(StartTime)) / 60)) ,
RuntimeLastMonth=iif( format_datetime(todatetime(StartTime), 'MM/yyyy') != format_datetime(todatetime(EventSubmissionTimestamp), 'MM/yyyy') , (datetime_diff('minute',startofmonth(EventSubmissionTimestamp) ,todatetime(StartTime)) / 60) ,0)
Which gives me following result.
Now I want to pivot the dates that I got this kind of table.
In a previous project I used the evaluate pivot command to pivot the column and sum the Runtimes , but now I have to columns (Lastmonth and this month) and I can't find a way to pivot the two columns.
| evaluate pivot(StartDate, sum(RuntimeLastMonth) , StopDate , sum(RuntimeThisMonth))
Is there someone who knows what I am missing in my pivot query ?