Solved

DAX - IF AND OR - Calculated column

Posted on 2016-08-26
12
88 Views
Last Modified: 2016-08-29
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
Comment
Question by:mikes6058
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 41771634
Hi,

pls try something like this

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

Regards
0
 
LVL 31

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 250 total points
ID: 41771651
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
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41775202
@Mike
How does the best chosen solution takes care of your requirement? :Confused:
Would you please clarify?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41775206
In fact that is not a DAX formula and you cannot insert a calculated column with that formula.
0
 

Author Comment

by:mikes6058
ID: 41775208
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
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41775212
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
 

Author Comment

by:mikes6058
ID: 41775220
Yes it is, I was impressed to learn that the double pipe (||) could be used for "or"
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41775227
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
 

Author Comment

by:mikes6058
ID: 41775240
I will do, please don't be so rude next time.

Mike
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41775247
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
 

Author Comment

by:mikes6058
ID: 41775264
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
 

Author Comment

by:mikes6058
ID: 41775266
Apologies if I was misunderstood.

Mike
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question