cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sbacalso
Frequent Visitor

Nested IF - powerquery

Hi,

Good day.
Im just new in Power Query and I have a situation.
I have columns "Source", "Trans Type", "SW Request Type" and I want to create new column that will capture the values of Column "Source" if both Columns "Trans Type" and "SW Request Type" are BLANK. And also, it will capture the values of Columns Trans Type and SW Request if they're not empty.


Please see expected output below.  Man Happy

Source     |  Trans Type | SW Request Type | New Column
---------------------------------------------------------------------
GAPS        |                    |                              | GAPS
HW           |                    |                              | HW
SW           |                    | SW CASE               | SW CASE
SW           |                    | Sold to CASE         | Sold to CASE
SW Rqst   | Channel      |                               | Channel    
SW Rqst   | Oppty         |                               | Oppty

Thanks you

2 ACCEPTED SOLUTIONS

Accepted Solutions
petrovnikitamai Resolver V
Resolver V

Re: Nested IF - powerquery

try to add custom column and use 

= if [Trans Type]<>null then [Trans Type] else if [SW Request Type]<>null then [SW Request Type] else [Source]

image.png

View solution in original post

Super User I
Super User I

Re: Nested IF - powerquery

@sbacalso Just an another way of doing without multiple IF statements.

 

Add a custom column as below in "Power Query Editor"

 

=List.Last(List.Select({[Source], [TransType], [SWRequestType]}, each Text.Length(_) <> 0 ))

image.png 



Did I answer your question? Mark my post as a solution !

Proud to be a Datanaut !





View solution in original post

4 REPLIES 4
petrovnikitamai Resolver V
Resolver V

Re: Nested IF - powerquery

try to add custom column and use 

= if [Trans Type]<>null then [Trans Type] else if [SW Request Type]<>null then [SW Request Type] else [Source]

image.png

View solution in original post

sbacalso
Frequent Visitor

Re: Nested IF - powerquery

Thank you @petrovnikitamai it works. 

themistoklis Memorable Member
Memorable Member

Re: Nested IF - powerquery

if [Trans Type] = null and [SW Request] = null then [Source]else if [Trans Type] <> null then [Trans Type] 
else if [SW Request] <> null then [SW Request]
else "No Value"

@sbacalso

You can insert the above formula in a new column

Super User I
Super User I

Re: Nested IF - powerquery

@sbacalso Just an another way of doing without multiple IF statements.

 

Add a custom column as below in "Power Query Editor"

 

=List.Last(List.Select({[Source], [TransType], [SWRequestType]}, each Text.Length(_) <> 0 ))

image.png 



Did I answer your question? Mark my post as a solution !

Proud to be a Datanaut !





View solution in original post

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors