cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Condition in CDS View - If Attribute X is empty, use Attribute Y

SCHNEIDERT
Active Contributor
11,811

Dear Experts,

is it possible use a condition in a CDS View like that:

If Attribute X is empty, insert value of Attribute Y ?

Use Case is the following:

We have address data for all of our Corporate Accounts as Company Address and also for some Contacts as the Private Address.

Now I'm able to create a report which includes the address data (City, zip code and so on) of both, Accounts and Contacts.

The challenge I'm facing is, that e.g. "City" are of course two different columns. In one column I can see the City of the Corporate Account and in the other one I can see the City of the Contact.

At the end I would like to have only ONE column with a City name. If a Contact has a City in his Private Address, that one should be used. If he has no private address, the address of the Corporate Account should be used.

Does anyone know if this is even possible and if so, how to do it?

BR Tobias

Accepted Solutions (0)

Answers (1)

Answers (1)

marc_dorais
Product and Topic Expert
Product and Topic Expert

Hello Tobias,

In your custom CDS view, you should be able to create a calculated field and use the function CASE to choose which city you want to use.

See this similar example

Best regards,
Marc

SCHNEIDERT
Active Contributor
0 Likes

Hi Marc,

great, I will try that out! Thank you and a happy new year! 🙂

BR Tobias

marc_dorais
Product and Topic Expert
Product and Topic Expert
0 Likes