Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
chrisbatson75
Frequent Visitor

PowerQuery if with multiple conditions AND OR

Should be simple

Research = if(or('Forced Receipts'[Cost Amt]>500, 'Forced Receipts'[OC Stat]="Closed","Required",""))

 

Doesnt work.

I want that it the Forced Receipts cost amount is mroe than $500 to print required in the field 

OF

if the OC Stat is = to closed, then print required.

 

What i am missing in the formual?

1 ACCEPTED SOLUTION
SteveCampbell
Memorable Member
Memorable Member

Hello,

 

When you say PowerQuery, are you writing this in the PowerQuery editor in the M language, or in DAX?

 

By the looks of your code it appears you are adding a column in DAX (PowerQuery is the query editor).

 

You are missing a closing bracket in the OR statement after "Closed":

 

 

Research =
IF (
    OR ( 'Forced Receipts'[Cost Amt] > 500, 'Forced Receipts'[OC Stat] = "Closed" ),
    "Required",
    ""
)

 

I would reccomend using the double bar || as an OR. You can nest multple OR statements (The AND equivilent is && ). Also, you can use BLANK() instead of "":

 

 

Research =
IF (
    'Forced Receipts'[Cost Amt] > 500
        || 'Forced Receipts'[OC Stat] = "Closed",
    "Required",
    BLANK()
)

 

 

 

 

If you are in PowerQuery, it is somwhat different. In the M language, the advanced editor could look like this:

Table.AddColumn(///Last Step///, "Research", each if [Cost Amt] >500 or [OC Stat] = "Closed" then "Required" else null)


relace

///Last Step///

with the name of your last step. Alternatively, you can use add conditional column.

 



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



View solution in original post

1 REPLY 1
SteveCampbell
Memorable Member
Memorable Member

Hello,

 

When you say PowerQuery, are you writing this in the PowerQuery editor in the M language, or in DAX?

 

By the looks of your code it appears you are adding a column in DAX (PowerQuery is the query editor).

 

You are missing a closing bracket in the OR statement after "Closed":

 

 

Research =
IF (
    OR ( 'Forced Receipts'[Cost Amt] > 500, 'Forced Receipts'[OC Stat] = "Closed" ),
    "Required",
    ""
)

 

I would reccomend using the double bar || as an OR. You can nest multple OR statements (The AND equivilent is && ). Also, you can use BLANK() instead of "":

 

 

Research =
IF (
    'Forced Receipts'[Cost Amt] > 500
        || 'Forced Receipts'[OC Stat] = "Closed",
    "Required",
    BLANK()
)

 

 

 

 

If you are in PowerQuery, it is somwhat different. In the M language, the advanced editor could look like this:

Table.AddColumn(///Last Step///, "Research", each if [Cost Amt] >500 or [OC Stat] = "Closed" then "Required" else null)


relace

///Last Step///

with the name of your last step. Alternatively, you can use add conditional column.

 



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.