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

Highlighted
Microsoft dkay84_PowerBI
Microsoft

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

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
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors