Forum Discussion

tipper1510's avatar
tipper1510
Brass Contributor
Dec 18, 2023

Use of TimeRange parameter in workbooks

Hi,

 

I use the timerange parameter as:

 

| where Timestamp >= {TimeRange:start} and TimeGenerated <= {TimeRange:end}

 

but need to incorporate into:

 

| where Timestamp between ( startofday(ago(14d)) .. endofday(ago(7d)) )

 

Any tips please...

 

Regards,

 

Tim

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor
    Hi Tim, I dont fully understand your question, are you trying to pass 14d and 7d into the syntax as a parameter. Usually you'd just use the {TimeRange:start} etc like you've shown.

    Or do you mean:

    | where Timestamp between ( startofday({TimeRange:start}) .. endofday({TimeRange:end}) )
    • tipper1510's avatar
      tipper1510
      Brass Contributor
      Hi Clive,

      I need to use the TimeRange parameter with the 14d ago and 7ago as need to get the previous weeks data for comparison but ensure I use the supplied initial TimeRange.

      Regards,

      Tim
      • Clive_Watson's avatar
        Clive_Watson
        Bronze Contributor

        tipper1510 

         

        Is this the type of result (using the Microsoft demo data), very simplified.

        Go to Log Analytics and run query

         

         

        // arg0
        let last30days=
        Heartbeat
        | where TimeGenerated between( ago(30d) .. now() )
        | summarize //min(TimeGenerated), max(TimeGenerated)
                 count()
                 by bin(TimeGenerated,1d)
        ;
        //arg1
        let last7days=
        Heartbeat
        | where TimeGenerated between( ago(14d) .. ago(7d) )
        | summarize //min(TimeGenerated), max(TimeGenerated)
                 count()
                 by bin(TimeGenerated,1d)
        ;
        union withsource=sourceTable last30days, last7days
        | render columnchart

Resources