Forum Discussion
IF Statement help with multiple variables
- 6 years ago
I started with the dataset below. Because I edited the file it reordered the columns.
[Value] is a Calculated Column.
Adding [RateType] is just a suggestion. You can accomplish what you asked (not adding a helper column) by doing:
Value = SWITCH( TRUE(), 'Table'[Name] = "John Doe" && 'Table'[Title] = "Project Executive", 65, 'Table'[Name] = "Jane Doe" && 'Table'[Title] = "Project Executive", 45, 'Table'[Title] = "Project Executive", 50, 25 )
Edit: Same idea after I re-read your requirement
I would probably just add a helper flag column to your dataset instead of hard-coding Name values.
Value =
SWITCH(
TRUE(),
'Table'[RateType] = 1 && 'Table'[Title] = "Project Executive", 65,
'Table'[RateType] = 2 && 'Table'[Title] = "Project Executive", 45,
'Table'[Title] = "Project Executive", 50,
25
)
- 95Bigbluetoy6 years agoHelper I
Thanks for the reply. I am rather new to Power Bi so trying to learn DAX. can be a bit confusing. Based on your reply, you have the same value for John and Jane Doe. In my original post, Jane Doe has a different value from John and from the other PE's. In my current dataset, my IF statement has multiple nested IF statements due to numerous job titles. This works great, until today when my boss emailed me with changes for just a few users. Previously all users with same job title has same value. now i need John Doe to have one value (65), Jane Doe to have a value of 40 and all other PE's to have a value of 50.
thanks for your help.
- 95Bigbluetoy6 years agoHelper I
Not sure i undestand. it looks like you are creating two new columns (Value and Rate Type). what is the 25 after the 50,? I also have about 15 other job titles that i currently have in my IF statement as well.
is there not a way to have conditions on the If statement to say that if the Title equals PE then 50 unless name equals John Doe, then 65 or if name equals Jane Doe then 40?
have to go into a meeting so will not be able to reply for a bit. thanks again for all your help.
- ChrisMendoza6 years agoResident Rockstar
I started with the dataset below. Because I edited the file it reordered the columns.
[Value] is a Calculated Column.
Adding [RateType] is just a suggestion. You can accomplish what you asked (not adding a helper column) by doing:
Value = SWITCH( TRUE(), 'Table'[Name] = "John Doe" && 'Table'[Title] = "Project Executive", 65, 'Table'[Name] = "Jane Doe" && 'Table'[Title] = "Project Executive", 45, 'Table'[Title] = "Project Executive", 50, 25 )- 95Bigbluetoy6 years agoHelper I
i would be able to add all my other job titles as well in this scenario and therefore would do away with my IF statement, correct?