1

I have a choice column (it can be a text column if that would work) called Month, with options for Jan to Dec.

I am trying to use column formatting to highlight rows where the chosen month is the same as the current month.

This is without a date column, or the Created column.

I have looked into the @now function but I am still stuck! any help would be greatly appreciated.

1
  • 1
    It will be easier if you use choices 1 to 12 for months while using "getMonth()" operator Oct 7, 2022 at 13:52

1 Answer 1

1

You can use JSON view formatting for this. Use choices from 1 to 12 in "Month" column and then use below JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if(Number([$Month]) == getMonth(@now) + 1, 'sp-field-severity--severeWarning', '')"
}

Output:

enter image description here

Documentation: view-list-formatting

3
  • 1
    For using January to December as text choices, you will require complex calculations in JSON. Oct 7, 2022 at 14:02
  • 1
    This works great thanks! Although, for me it is seeing October as number 9 (I am guessing 0 = January, rather than 1). How did yours work so that 10 = October instead of 9 = October?
    – B4N3
    Oct 7, 2022 at 14:29
  • 1
    I pasted the wrong JSON earlier. I have corrected it now, check updated answer. Oct 7, 2022 at 15:18

Your Answer

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

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