SOLVED

Compare 2 columns of a Sharepoint list

Copper Contributor

Hello, I would like to compare the "Estimation" column with the "Temps passe" column if the  "Statut" column is selected as "Terminée" with this method :

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#create-s...

444456464_0-1642777542374.png

 

My SharePoint list with the columns concerned :

444456464_1-1642778040100.png

I tried this but it doesn't work, and I couldn't even add the condition to it "if the "Statut" column has the choice "Terminée" :

 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "class": "=if([$Tempspasse] > [$Estimation], 'sp-field-trending--up', 'sp-field-trending--down')",
        "iconName": "=if([$Tempspasse] > [$Estimation], 'SortUp', if([$Tempspasse] < [$Estimation], 'SortDown', ''))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "[$Tempspasser]"
    }
  ]
}

 

 

 

Can you help me please ?

4 Replies
best response confirmed by 444456464 (Copper Contributor)
Solution

@444456464 try the following:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$Statuit] == 'Terminée' && @currentField > [$Estimation], 'sp-field-trending--up', if([$Statuit] == 'Terminée' && @currentField < [$Estimation], 'sp-field-trending--down', ''))"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if([$Statuit] == 'Terminée' && [$Tempspasse] > [$Estimation], 'SortUp', if([$Statuit] == 'Terminée' && [$Tempspasse] < [$Estimation], 'SortDown', ''))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "[$Tempspasse]"
    }
  ]
}

 

which results in:

 

trendIcon.png

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

Thank you so much !
How did you get the bubble like display in the Statuit column?

@jfi74 it's just the out-of-the-box choice pills. Click the down arrow next to the Choice column heading, select column settings -> format this column -> choice pills.

choicePills.png

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

1 best response

Accepted Solutions
best response confirmed by 444456464 (Copper Contributor)
Solution

@444456464 try the following:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$Statuit] == 'Terminée' && @currentField > [$Estimation], 'sp-field-trending--up', if([$Statuit] == 'Terminée' && @currentField < [$Estimation], 'sp-field-trending--down', ''))"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if([$Statuit] == 'Terminée' && [$Tempspasse] > [$Estimation], 'SortUp', if([$Statuit] == 'Terminée' && [$Tempspasse] < [$Estimation], 'SortDown', ''))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "[$Tempspasse]"
    }
  ]
}

 

which results in:

 

trendIcon.png

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

View solution in original post