Reputation: 7260
I have table with the fields Amount, Condition1, Condition2
.
Example:
Amount Condition1 Condition2
----------------------------------
123 Yes Yes
234 No Yes
900 Yes No
I want to calculate the 20% of the amount based on condition:
If both Condition1
and Condition2
is Yes then calculate 20%
else 0
.
My try: I tried with conditional custom column but unable to add AND
in IF
in the query editor.
Upvotes: 3
Views: 55578
Reputation: 3656
Try to create a new calculated column. And Use below DAX query:
new_column = IF(Conditition1 = "Yes", IF(Condititon2 = "Yes",Amt * 0.2 ,0), 0)
Upvotes: 2
Reputation: 40204
You can write a conditional column like this:
= IF(AND(Table1[Condition1] = "Yes", Table1[Condition2] = "Yes"), 0.2 * Table1[Amount], 0)
Or you can use &&
instead of the AND
function:
= IF(Table1[Condition1] = "Yes" && Table1[Condition2] = "Yes", 0.2 * Table1[Amount], 0)
Or an even shorter version using concatenation:
= IF(Table1[Condition1] & Table1[Condition2] = "YesYes", 0.2 * Table1[Amount], 0)
Upvotes: 5