Forum Discussion

alexwarde's avatar
alexwarde
Copper Contributor
Dec 17, 2021

Calculated Field in SharePoint List. HELP

Hi guys,
Struggling to make a calculated column of Today's date dependant on a choice column. See below.
When an item is added to the SharePoint List the case status column is set as default as "Open".
When this is changed to "Closed" I need a calculated field called "Case Closed Date" to set the date as Today() only when the case status field has been changed to Closed.
Any help would be greatly appreciated.
Thanks,
  • Maggan_W's avatar
    Maggan_W
    Brass Contributor

    alexwarde 

     

    If you are using modern lists:

     

    First, create a new column, HiddenTodayColumn, of type Date and Time. Select Default value = calculated value: =Today().

    Second, create a column, Case Closed Date,  that will be populated based on the value of the Status column.

    In column Case Closed Date, select Column settings - Format this column. Paste this code sample:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=if([$Status] == 'Closed',[$HiddenTodayColumn], 'Another value or empty')"
    }

     

    You probably need to tweak the code in order to meet your requirements, but hopefully you got some idea on the possibilities.

     

Resources