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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
damonkimble
Frequent Visitor

DAX multiple condition in a single IF condition

Hi,

I have three variables called:

Append Sales Invoices[Amount] = Type Decimal Number

Append Sales Invoices[Header.No] = Type Text

Append Sales Invoices[Quantity] Type Decimal Number

 

I am trying to customize a column called TSIP Hours where the output is basically Append Sales Invoices[Quantity] that goes through an IF condition.

When the Append Sales Invoices[Amount] is 0 and Append Sales Invoices[Header.No] is either "20144" or "20140" then Output is the Append Sales Invoices[Quantity]. I put the formula down below. The problem is, it's populating the quantity regardless of the If condition - so if the quantity is 1 or greater, it still populates where it should only populate when Amount is 0. 

 

TSIP Hours = IF('Append Sales Invoices'[Amount] = 0 && 'Append Sales Invoices'[Header.No_] = "20144" || "20140", 'Append Sales Invoices'[Quantity])
 
 This formula only populates on the first condition when amount is 0 but doesn't meet the second condition with the &&/||
TSIP Hours = if('Append Sales Invoices'[Amount] = 0 && ('Append Sales Invoices'[Header.No_] = "20144" || "20140"), 'Append Sales Invoices'[Quantity])
1 ACCEPTED SOLUTION

Hi, @damonkimble 

According to this error message, you can change the DAX formula like this and check if it can work:

TSIP Hours =

if('Append Sales Invoices'[Amount] = 0 &&

'Append Sales Invoices'[Header.No_] in {"20144","20140"},

'Append Sales Invoices'[Quantity],BLANK())

If this DAX can work, would you like to mark my reply as a solution?

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-robertq-msft
Community Support
Community Support

Hi, @damonkimble 

According to your DAX formula, I think the second condition in your IF() function is incorrect, you can change the DAX formula like this:

TSIP Hours = 
if('Append Sales Invoices'[Amount] = 0 && 
('Append Sales Invoices'[Header.No_] in {"20144","20140"}, 
'Append Sales Invoices'[Quantity])

 

And you can get what you want.

If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, thank you for the response. Unfortunately, I get an error message "Operator or expression '()' is not supported in this context. I'll attach a screenshot of the data provided. power bi dax.PNG

Hi, @damonkimble 

According to this error message, you can change the DAX formula like this and check if it can work:

TSIP Hours =

if('Append Sales Invoices'[Amount] = 0 &&

'Append Sales Invoices'[Header.No_] in {"20144","20140"},

'Append Sales Invoices'[Quantity],BLANK())

If this DAX can work, would you like to mark my reply as a solution?

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@damonkimble Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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