Forum Discussion
New Conditional Column from Two Other Columns in M
- 6 months ago
This should solve your issue.
= Table.AddColumn(previousStep, "ConditionalColumn", each if [Number Category] = 3 and [Pet Type] = "Dog" then "Adopted" else [Pet Type], type text)
jgeddes Yes, I removed the old column and added the new "conditional column" to the graph. I also inserted a new table visual to verify and the "adopted" is not there, it is "dog". I'm not sure what is wrong. In my data, the pet type is another conditional column, but it is earlier in the applied steps. Is this throwing it off?
An earlier conditional step should not matter as long as the conditional column we created references the immediate previous step.
If the "Conditional Column" is loaded into the report, and you can view the correct data in the table view, I cannot explain why you are getting the result you are.
I will share my pbix file to see if you can compare between and find the issue.
- UnearthlyFalcon6 months agoAdvocate I
I needed to change the column type to text for the original two columns, that fixed it!
- UnearthlyFalcon6 months agoAdvocate I
I can't see the correct data in the table view either, neither in a visual or the power querry. My data is very large though and power querry can't load enough of it to preview what I need to see. I tried to filter by "3" in the category column but it doesn't even think a 3 (or a 2 for that matter) exiss because of the data quantity.
Regardless, I appreciate your help! My code is exactly what you provided. I'll try to keep playing around with different things to see if I can get it to work. I'll go ahead aand mark your answer as the solution, because it should be working for this type of situation haha. Thank you!