Trying to add a view to a spo event list that get the total duration of the events in the list. I found a built-in Duration field accessible though PNP Powershell (e.g. $event.fieldValues.Duration) that seems to be reporting duration in seconds. I can add the field to a view using Add/Set-PNPView, but when I try adding -aggregations "<FieldRef Name='Duration' Type='Sum'/>" to the command, I get count=undefined on the list view.

I'm not used to using the -aggregations parameter so I'm not sure of the syntax and have found documentation to be fairly thin on that point.

1 Answer 1


You will need to manually create the Duration column in Type of Number in the event list first.

Here is the sample command I test with:

Set-PnPView -List "Test calendar" -Identity "All Events" -Fields "ID","Title","Start Time","End Time","Duration" -Aggregations "<FieldRef Name='Duration' Type='Sum'/>"

And the outcome: enter image description here

  • I tried that command line and I'm still getting "count=undefined." In your example, you're using the built-in Duration field, yes?
    – steam23
    Commented Jan 29, 2021 at 14:06
  • @steam23 Yes, custom column in the list and the built-in Duration field in the PowerShell. Commented Feb 1, 2021 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.