cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nischal Helper I
Helper I

Re: IF Statement using Power Query

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

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
Regular 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
Regular 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
New Member

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
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors