• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

DAX - IF AND OR - Calculated column

I have the column below in a powerpivot date model

Payment terms
60
45
30
35

I want to add a calculated column with an if statement that will return new values based on the following conditions

If column "payment terms" contains values 45 or 30 or 35 then return 30 and if it contains 60 then return "58"

I know in standard excel this formula would work =IF(OR(A1=45,A1=35,A1=30),30,58)

I've tried replicating in my data model but I'm getting an error.

Mike
0
mikes6058
Asked:
mikes6058
  • 6
  • 5
2 Solutions
 
Rgonzo1971Commented:
Hi,

pls try something like this

=IF((A1=45 || A1=35 || A1=30),30,58)

Regards
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try this....

=IF(PaymentTerms[Payment Terms]=60,58,30)

Open in new window

Refer to the attached for more details.
DAX-Formula.xlsx
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Mike
How does the best chosen solution takes care of your requirement? :Confused:
Would you please clarify?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
In fact that is not a DAX formula and you cannot insert a calculated column with that formula.
0
 
mikes6058Author Commented:
Sorry I could just as easily have given the points to you. I have another question I've just opened if you're interested.

Mike
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
No. I am not concerned with the points here but I just wanted to know that how did you choose the best solution?
Is that a DAX formula?
0
 
mikes6058Author Commented:
Yes it is, I was impressed to learn that the double pipe (||) could be used for "or"
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Wow. What a great explanation indeed!
Please use request attention and remove my solution from the assisted solution.
That would be a favor to me.
0
 
mikes6058Author Commented:
I will do, please don't be so rude next time.

Mike
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Please don't misunderstand me. I was not rude at all.
I was just surprised how did the best solution could be implemented in Power Pivot Data Model.
You know that the A1 style notations don't work in Power Pivot. And as far as using || for OR is concerned, that's a pretty basic thing in Power Pivot.
0
 
mikes6058Author Commented:
I know, although I think Rogonzo was aware that I wanted a DAX solution. He provided the same logic in my previous question where I specifically asked for a DAX solution (link below). We both knew that the "A" reference must be substituted with a column reference.

https://www.experts-exchange.com/questions/28965828/IF-OR-AND-Statements-EXCEL.html

Although like I said, I could just as easily have given the points to you.

Thanks
Mike
0
 
mikes6058Author Commented:
Apologies if I was misunderstood.

Mike
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now