cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nischal Regular Visitor
Regular Visitor

Re: IF Statement using Power Query

hi , when i am trying to get two conditions using and function its throwing an error

dkay84_PowerBI New Contributor
New Contributor

Re: IF Statement using Power Query

example:

 

if 'table'[field] = {condition1} or 'table'[field] = {condition2} then {output1} else {output2}

 

You can replace the "or" with "and" depending on your logic.  Obviously your conditions don't have to be based on "=" either.

 

Also you can nest ifs:

 

example:

 

if 'table'[field] = {condition1} then if 'table'[field] = {condition2} then {output1} else {output2} else {output3}

Tavo015 Frequent Visitor
Frequent Visitor

Re: IF Statement using Power Query

Why this code not run? 

 

= Table.AddColumn(#"Added Custom", "PENDIENTES DE GOCE", each if ([DÍAS DE VACACIONES PENDIENTES]) > 1 then "1" else Null)

 

Thanks a lot

Tavo015 Frequent Visitor
Frequent Visitor

Re: IF Statement using Power Query

Why this code not run? Is it good?

 

if ([DÍAS DE VACACIONES PENDIENTES]) > 1 then "1" else Null

 

Thanks a lot

Highlighted
DMPBR Occasional Visitor
Occasional Visitor

Re: IF Statement using Power Query

I signed up purely to give you kudos for this bit:


@MarcelBeug wrote:

PQ is case sensitive and if...then...else is all lower case, just like null.

 


My logic was right but turns out I had capitalised the THEN statement which threw an unexpected tag error.

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 382 members 3,296 guests
Please welcome our newest community members: