Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from PopWarner/master
Column sample for tolerance comparison using abs() operator
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
column-samples/number-abs-tolerance-comparison/number-abs-tolerance-comparison.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.