Skip to content

Commit 39be0f1

Browse files
authored
Merge pull request MicrosoftDocs#3127 from MicrosoftDocs/master
Merge master to live
2 parents 76829a3 + d0bb134 commit 39be0f1

File tree

8 files changed

+118
-6
lines changed

8 files changed

+118
-6
lines changed

powerapps-docs/developer/common-data-service/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
href: use-fetchxml-left-outer-join-query-records-not-in.md
2828
- name: Page large result sets with FetchXML
2929
href: org-service/page-large-result-sets-with-fetchxml.md
30+
- name: Use column comparison in queries
31+
href: column-comparison.md
3032
- name: "Use SQL to query data (Preview)"
3133
href: cds-sql-query.md
3234
- name: Saved Queries
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "Use column comparison in queries (Common Data Service) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
3+
description: "Learn how to compare columns when querying business data." # 115-145 characters including spaces. This abstract displays in the search result.
4+
ms.custom: ""
5+
ms.date: 07/08/2020
6+
ms.reviewer: "pehecke"
7+
ms.service: powerapps
8+
ms.topic: "article"
9+
author: "NHelgren" # GitHub ID
10+
ms.author: "nhelgren" # MSFT alias of Microsoft employees only
11+
manager: "mayadu" # MSFT alias of manager or PM counterpart
12+
search.audienceType:
13+
- developer
14+
search.app:
15+
- PowerApps
16+
- D365CE
17+
---
18+
19+
# Use column comparison in queries
20+
21+
In the Common Data Service, users can perform a column comparison for the
22+
following condition operators using FetchXML, Web API, or the SDK API:
23+
24+
- Equal
25+
- NotEqual
26+
- GreaterThan
27+
- GreaterEqual
28+
- LessThan
29+
- LessEqual
30+
31+
This will allow the comparison of an attribute against a specific value and
32+
return all found records, or allow the comparison of two attributes to return
33+
all records with a matching value.
34+
35+
## Limitations
36+
37+
Listed below are the limitations for the current Common Data Service column comparison support.
38+
39+
- Only two columns may be compared at a time.
40+
- Multi-value condition operators are not supported (i.e., "in").
41+
- Extended condition operators are not supported (i.e., "creditlimit \> spends+1000").
42+
- Incompatible attribute comparison is not supported. For example, "int vs. int" attributes is a valid comparison but "int vs. string" attributes is not valid comparison.
43+
44+
## Column comparison using FetchXML
45+
46+
The following example shows how to compare columns using FetchXML:
47+
48+
```xml
49+
<fetch>
50+
<entity name='contact' >
51+
<attribute name='firstname' />
52+
<filter>
53+
<condition attribute='firstname' operator='eq' valueof='lastname'/>
54+
</filter>
55+
</entity>
56+
</fetch>
57+
```
58+
59+
For FetchXML requests, a new node `valueof` has been added inside the condition
60+
node. The `valueof` tag is used to identify the attribute that is being compared
61+
to the selected attribute. In the above example, the 'firstname' column is being
62+
compared against the 'lastname' column and will return any records that contain
63+
the same value across both attributes.
64+
65+
### See Also
66+
67+
[Use FetchXML to construct a query](use-fetchxml-construct-query.md)
68+
[Column comparison using the Web API](webapi/query-data-web-api.md#column-comparison-using-the-web-api)
69+
[Column comparison using the SDK API](org-service/use-conditionexpression-class.md#column-comparison-using-the-sdk-api)

powerapps-docs/developer/common-data-service/org-service/use-conditionexpression-class.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,41 @@ condition3.Operator = ConditionOperator.Equal;
8282
condition3.Values.Add(AccountState.Active);
8383

8484
```
85-
85+
86+
## Column comparison using the SDK API
87+
88+
The following example shows how to compare columns using SDK API and the Organization service:
89+
90+
```csharp
91+
public ConditionExpression
92+
(
93+
string attributeName,
94+
  ConditionOperator conditionOperator,
95+
  bool compareColumns,
96+
  object value
97+
)
98+
99+
public ConditionExpression
100+
(
101+
string attributeName,
102+
ConditionOperator conditionOperator,
103+
  bool compareColumns,
104+
  object[] values
105+
)
106+
```
107+
108+
In the SDK, two APIs are introduced to support column comparison. The
109+
first identifies the original attribute, the second allows
110+
for the inclusion of the attribute you want to compare it against.
111+
112+
If `compareColumns` is passed in as `true`, it will compare the two attributes
113+
and return all records that match.
114+
115+
If a `false` value is passed, it will return all records for one attribute and
116+
return values that match the provided value.
117+
118+
More information: [Use column comparison in queries](../column-comparison.md)
119+
86120
### See also
87121
[Building Queries](build-queries-with-queryexpression.md)
88122
[Build Queries with QueryExpression](build-queries-with-queryexpression.md)

powerapps-docs/developer/common-data-service/webapi/query-data-web-api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,16 @@ The change tracking feature allows you to keep the data synchronized in an effic
861861

862862
More information: [Use change tracking to synchronize data with external systems](../use-change-tracking-synchronize-data-external-systems.md).
863863

864+
## Column comparison using the Web API
865+
866+
The following example shows how to compare columns using the Web API:
867+
868+
```http
869+
https://<environment-root>/contacts?$select=firstname&$filter=firstname eq lastname
870+
```
871+
872+
More information: [Use column comparison in queries](../column-comparison.md)
873+
864874
### See also
865875

866876
[Web API Query Data Sample (C#)](samples/query-data-csharp.md)<br />

powerapps-docs/maker/portals/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: sandhangitmsft
55
ms.service: powerapps
66
ms.topic: conceptual
77
ms.custom:
8-
ms.date: 07/06/2020
8+
ms.date: 07/14/2020
99
ms.author: sandhan
1010
ms.reviewer: tapanm
1111
---
@@ -26,7 +26,7 @@ These capabilities feature a revamped end-to-end experience for makers to quickl
2626

2727
### See also
2828

29-
- [Microsoft Learn: Get started with Power Apps portals](https://docs.microsoft.com/earn/paths/get-started-power-apps-portals/)
29+
- [Microsoft Learn: Get started with Power Apps portals](https://docs.microsoft.com/learn/paths/get-started-power-apps-portals/)
3030
- [Portal admin center](admin/admin-overview.md)
3131
- [Portal management app](configure/configure-portal.md)
3232
- [Portal site settings](configure/configure-site-settings.md)

powerapps-docs/user/export-to-excel-online.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ search.audienceType:
1616
search.app:
1717
- PowerApps
1818
- D365CE
19-
- D365CE
2019
---
2120
# Export your data to Excel Online
2221

powerapps-docs/user/import-data.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ search.audienceType:
1616
search.app:
1717
- PowerApps
1818
- D365CE
19-
- D365CE
2019
---
2120
# Import data
2221

powerapps-docs/user/track-your-progress-with-dashboard-and-charts.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ search.audienceType:
1616
search.app:
1717
- PowerApps
1818
- D365CE
19-
- D365CE
2019
---
2120
# Track your progress with dashboards and charts
2221

0 commit comments

Comments
 (0)