Search code examples
azure-data-explorerkqlazure-log-analytics-workspace

Line Graph where each line is a column in the same table


I am trying to make a line graph in Azure Data Explorer, I have a single table and I am trying to make each line in the line graph be based on a column in that table.

Using a single column works just fine with the below query

scandevicedata
| where SuccessFullScan == 1
| summarize SuccessFulScans = count() by scans = bin(todatetime(TransactionTimeStampUtc), 30s)

The problem is now I want to add a second column from the same table like this

scandevicedata
| where UnSuccessFullScan == 1
| summarize UnSuccessFulScans = count() by scans = bin(todatetime(TransactionTimeStampUtc), 30s)

As you can see the first query takes out successful scans and the second query takes out Un Successful scans and now I want to combine them in the same output and do a graph on them but I cant figure out how to do this since they are different columns

How can I achieve this?


Solution

  • You could use the countif() aggregation function :

    scandevicedata
    | summarize
           Successful = countif(SuccessFullScan == 1),
           Unsuccessful = countif(UnsuccessFullScan == 1) 
        by bin(todatetime(TransactionTimeStampUtc), 30s)
    | render timechart