Ifelse function issue

Hi all,
I’m trying to add a calculated field by ifelse function. The field looks at column firstPublishDateLegacy and if it’s evaluated as NULL, it should return minPublishDate. I guess the syntax is correct but I cannot save this because of an unknown errror. Any ideas what’s the blocker here? Thanks in advance.

Hi @Rad What is the data type of firstPublishDateLegacy field?

Regards - Sanjeeb

1 Like

Hi,

you can use COALESCE for this.

Thomas

2 Likes

@Sanjeeb2022

firstPublishDateLegacy - String
minPublishDate - Date

Should these fields reflect as same datatype? If so - firstPublishDateLegacy is loaded via csv file, should i convert this to date?

Hi @Rad - Ideally your return statement should be date in both cases, for example if firstPublishDateLegacy ( which is type string) then you are retuning minPublishDate ( which is a date) and if it is not null, then you are returning string. Ideally both should be in same data type. Is my understanding correct?

Regards - Sanjeeb

1 Like

@Sanjeeb2022 you understanding is correct, let me try to amend datatype, so will check if it’s working.

2 Likes

@Sanjeeb2022 I’m not sure why QS reads this csv data as string, whenever I’m trying to amend it manually in QS i’m getting rejected:

source file:
image

qs:

image

Hi @Rad - can you please give the format as dd/MM/YYYY HH:mm? I tested with sample data and it worked for me. see the below screenshot.

Regards - Sanjeeb

1 Like

@Sanjeeb2022 it’s not working for me, i’m getting rejected

image

I’ve just checked the sample as you did and it’s working but when i’m joining the file to a larger dataset it’s failing.

Any hints?

@Sanjeeb2022 please disregard, i managed to solve it. I’ve created a dataset from the file and then was able to join this further.

1 Like

Glad you found a solution, @Rad!