Search code examples
azureazure-data-factory

How to have more than one case statement for a column in adf?


for example I have a column date and I have two conditions that needs to be fulfilled.

1st case(region = 'a', today, tomorrow) 2nds case(is null(abs), tomorrow, day after)

how do I combine these both?

case(region = 'a', toady, is null(abs), tomorrow, day after)

is this correct way of doing this


Solution

  • case(region = 'a', toady, is null(abs), tomorrow, day after)

    If the value of the region column is 'a', the expression will return today. If the value of the abs column is null, the expression will return tomorrow. Otherwise, the expression will return day after. In order to do this in mapping data flow, you can give the expression as

    case(region == 'a', currentUTC(), isNull(abs), addDays(currentUTC(),1) , addDays(currentUTC(),2))
    

    If we apply this expression to the following dataset:

    region abs
    a 10
    b null
    c 20

    Output:

    enter image description here

    For the first row, the value of the region column is 'a', so the expression will return the current date and time in UTC format. For the second row, value of region is not 'a' and the value of the abs column is null, so the expression will return the current date and time in UTC format plus one day. For the third row, neither of the conditions are met, so the expression will return the default value day after current date and time in UTC format plus two days.