Skip to content

Commit

Permalink
Merge pull request #135 from PopWarner/master
Browse files Browse the repository at this point in the history
Column sample for tolerance comparison using abs() operator
  • Loading branch information
VesaJuvonen committed Mar 10, 2019
2 parents 76d0516 + b63686f commit fed1fa4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
@@ -0,0 +1,27 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"attributes": {
"class": "=if(abs([$Actual]-[$Expected])<=[$Tolerance], 'sp-field-trending--up','sp-field-trending--down')",
"iconName": "=if(abs([$Actual]-[$Expected])<=[$Tolerance], 'LikeSolid','DislikeSolid')"
}
},
{
"elmType": "span",
"txtContent": "[$After]"
},
{
"elmType": "span",
"txtContent": "=if(abs([$Actual]-[$Expected])<=[$Tolerance], 'Pass','Fail')",
"attributes": {
"class": "=if(abs([$Actual]-[$Expected])<=[$Tolerance], 'sp-field-trending--up','sp-field-trending--down')"
},
"style": {
"padding-left": "5px"
}
}
]
}
44 changes: 44 additions & 0 deletions column-samples/number-abs-tolerance-comparison/readME.md
@@ -0,0 +1,44 @@
# Determine Tolerance Comparison using abs()

## Summary

Display if a value is within the expected tolerance.

To determine success, the column formatting definition subtracts the "Actual" value from the "Expected" value and applies the "abs()" operator to retrieve the absolute value. The result is compared to the "Tolerance" column value to determine pass or fail.

An Office UI Fabric class and icon is also applied to provide visual indicators of Pass or Fail.


### Screenshot
![screenshot of the sample](./screenshot.jpg)


## Column Types
The columns used in this sample were created as "Number" column types.

## View requirements
- N/A

## Sample

Solution|Author(s)
--------|---------
number-abs-tolerance-comparison.json | [David Warner II](https://twitter.com/davidwarnerii) / [Warner.Digital](http://warner.digital)

## Version history

Version|Date|Comments
-------|----|--------
1.0|March 8, 2019|Initial release

## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

---

## Additional notes

- [Use column formatting to customize SharePoint](https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting)


<img src="https://telemetry.sharepointpnp.com/sp-dev-list-formatting/column-samples/number-abs-tolerance-comparison" />
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fed1fa4

Please sign in to comment.