Fill zero in the table for timechart

Occasional Contributor

Hi, I would like to create a timechart for high daily number of incident in the past 7-day. However, not everyday has high incident. How could I fill the 0 into the result if that day has no high incident?

 

I had the similar ticket before: https://techcommunity.microsoft.com/t5/microsoft-sentinel/barchart-when-the-returned-result-is-zero/...

I am not sure if i need to create the dynamic object for the past 7-day.

 

Thanks.

SecurityIncident
| where Severity == "High"
| summarize StartTime = startofday(min(TimeGenerated)), count() by Severity, IncidentNumber
| summarize count() by bin(StartTime,1d)

 

 

 

Steven_Su_0-1646559423139.png

 

 

4 Replies

@Steven_Su 

 

Take a look at make-series, something like this example

 

SecurityIncident
| where Severity == "High"
| make-series count(), default=0 on TimeGenerated from ago(7d) to now() step 1d by IncidentNumber
| project TimeGenerated, count_
| render columnchart  

 

Clive_Watson_0-1646586002763.png

 




@Clive_Watson 

Hi Clive, since there are multiple IncidentNumber generated within a single day, the chart will be like this. How could I just make each day a single bar instead of showing multiple colors of portions? Thank you.

 

 

Steven_Su_1-1646619120175.png

 

 

@Steven_Su 

SecurityIncident
| where Severity == "High"
| make-series count(), default=0 on TimeGenerated from ago(7d) to now() step 1d // by IncidentNumber
| project TimeGenerated, count_
| render columnchart with (title = "Total Incidents per Day")

@Clive_Watson 

Yes the approach works. But one more question, if the data is 0 in the past 7 day, is it possible to still post the graph instead of showing the message "The query returned no results."? Thanks