Forum Discussion
IF DAX
- 8 years ago
BurakTurk - Not sure what you're trying to do here, but here's a breakdown of the DAX I used:
NewValue = IF(File[Value]="YES", "1", IF(File[Value]="NO", "0", File[Value]))
1. Create new calculated column called "NewValue"
2. If File[Value] = "YES" then insert a "1" into NewValue
3. If File[Value] = "NO", then insert a "0" into NewValue
4. If File[Value] is not equal to either YES or NO, then insert the value of File[Value] (that would be your original 2, 3, 4, ...) into NewValue.
The result is a column (NewValue) in the same table that has either a 1, a 0, or the original number from File[Value] in it. Is that not what you wanted? Not sure what you mean by "file [value] part, unfortunately, does not work on its own"; I tested it in PowerBI and it works.
BurakTurk - Not sure what you're trying to do here, but here's a breakdown of the DAX I used:
NewValue = IF(File[Value]="YES", "1", IF(File[Value]="NO", "0", File[Value]))
1. Create new calculated column called "NewValue"
2. If File[Value] = "YES" then insert a "1" into NewValue
3. If File[Value] = "NO", then insert a "0" into NewValue
4. If File[Value] is not equal to either YES or NO, then insert the value of File[Value] (that would be your original 2, 3, 4, ...) into NewValue.
The result is a column (NewValue) in the same table that has either a 1, a 0, or the original number from File[Value] in it. Is that not what you wanted? Not sure what you mean by "file [value] part, unfortunately, does not work on its own"; I tested it in PowerBI and it works.
I have to agree with tjd that this looks to be the solution to your issue BurakTurk. The only thing I can think to add to tjd's solution would perhaps be to do it this way to ensure a numeric number column:
NewValue = IF(File[Value]="YES", 1, IF(File[Value]="NO", 0, VALUE(File[Value])))
Now, once you have the NewValue column you can create a table or matrix based upon your category column. If you really want what you are saying, which is a new column with the total for each category I guess? You could do something like:
NewTotal = SUMX(FILTER(File,File[Category]=EARLIER(File[Category])),File[NewValue])
That should give you a new column where each A row has the total for all A's and where each B row has a total for all B's.