The CONCAT function is commonly used to merge multiple fields into a single string. However, when any of the concatenated fields contain a NULL value, the result of the concatenation is NULL. This behavior is particularly important when working with data that may have missing or empty values.
Consider the following SQL query:
SELECT
CONCAT(ssot__Individual__dlm.ssot__FirstName__c, ' - ', ssot__Individual__dlm.KQ_Id__c) AS FullName_KQId__c,
COUNT(ssot__Individual__dlm.ssot__Id__c) AS RecordCount__c
FROM ssot__Individual__dlm
GROUP BY CONCAT(ssot__Individual__dlm.ssot__FirstName__c, ' - ', ssot__Individual__dlm.KQ_Id__c);
In this query:
FullName_KQId__c is created by concatenating ssot__FirstName__c and KQ_Id__c with a hyphen (-) as a separator.
If either ssot__FirstName__c or KQ_Id__c is NULL, the entire FullName_KQId__c field will be NULL.
| ssot__FirstName__c | KQ_Id__c | FullName_KQId__c |
|---|---|---|
| John | 123 | John - 123 |
| Jane | NULL | NULL |
| NULL | 456 | NULL |
To avoid NULL values impacting the concatenated result, consider using a CASE statement to replace NULL values with an empty string. For example:
SELECT
CONCAT(
CASE WHEN ssot__Individual__dlm.ssot__FirstName__c IS NULL THEN '' ELSE ssot__Individual__dlm.ssot__FirstName__c END,
' - ',
CASE WHEN ssot__Individual__dlm.KQ_Id__c IS NULL THEN '' ELSE ssot__Individual__dlm.KQ_Id__c END
) AS FullName_KQId__c,
COUNT(ssot__Individual__dlm.ssot__Id__c) AS RecordCount__c
FROM ssot__Individual__dlm
GROUP BY
CONCAT(
CASE WHEN ssot__Individual__dlm.ssot__FirstName__c IS NULL THEN '' ELSE ssot__Individual__dlm.ssot__FirstName__c END,
' - ',
CASE WHEN ssot__Individual__dlm.KQ_Id__c IS NULL THEN '' ELSE ssot__Individual__dlm.KQ_Id__c END
);
If any field in the CONCAT function is NULL, the entire result is NULL.
Use a CASE statement to replace NULL values with an empty string and ensure concatenation works as expected.
Proper handling of empty values can prevent unexpected data loss and improve the accuracy of reports.
By implementing these best practices, you can ensure your Calculated Insights remain reliable and meaningful even when dealing with incomplete data.
004269012

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.