question

ewinkiser avatar image
0 Votes"
ewinkiser asked ewinkiser commented

USING IF IN MAPPING DATA FLOWS

Hi! @MarkKromer-MSFT (or anyone who can answer this :-)

I am running out of time so I hope you don't mind another Mapping Data Flow question. I have been working on this but no solution. I have the following data, Native, Naturalized, etc shown below. They have to be mapped to my ADF Mapping Data Flow Output csv document so that 1 shows for Native, 2 for Naturalized and so on. How can I do this with Data Flows? I tried if but it didn't work.


1--> Native
2--> Naturalized
3--> Alien Permanent
4--> Alien Temporary
5--> Alien
N-->Not Indicated

Thanks!
Mike Kiser

azure-data-factory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MarkKromer-2402 avatar image
0 Votes"
MarkKromer-2402 answered ewinkiser commented

Are you trying to map the strings (Native, Naturalized ...) to an enum value (1,2,...)?

If so, how about a case statement? https://docs.microsoft.com/en-us/azure/data-factory/data-flow-expression-functions#case

i.e.

case (
column == 'Native', 1,
column == 'Naturalize', 2,
.
.
.
)

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @MarkKromer-MSFT

I got it to work! It was the Copy Activity prior to the Data Flow that didn't have that column mapped.

A million thanks!!
Mike Kiser

1 Vote 1 ·

Thanks @MarkKromer-MSFT ! yes, I am trying to do that. I wasn't aware we could do case in Data Flows...let me try it.

Really appreciate your advice!
Mike Kiser

0 Votes 0 ·

Hi @MarkKromer-MSFT

I tried my best shot and also watched your awesome vid on cases, but I am getting back Nulls for that column. Please see below screenshots.......

Any suggestions? I am so under the gun to get this working.
Thanks!
Mike Kiser

118419-screenshot-2021-07-27-213536.jpg118395-screenshot-2021-07-27-213625.jpg


0 Votes 0 ·

Take out the chances of case differences or extraneous spaces ... and use single quotes for string values like this:

lower(trim(Citizenship)) == 'native'

1 Vote 1 ·

Hi @MarkKromer-MSFT ,
I gave it my best shot; please see the screen shots below; all columns in the source are "Native" so there should be a 1 in the citizenship column:

[1]: /answers/storage/attachments/118469-image.png

[2]: /answers/storage/attachments/118396-image.png


Thanks!
Mike

0 Votes 0 ·
image.png (73.8 KiB)
image.png (73.8 KiB)