Forum Discussion
DAX Recategorise
Hi All,
I am hoping to get a quick hand on how to create a DAX column in my model.
I am looking to recategorise Individual rows with a DAX expression where a user could fall into one of two categories (A or B) and in any case where a user has been tagged as category A, we want to recategorise those other rows as category A also. My original data looks like this:
| User | Category |
| 1 | A |
| 1 | B |
| 1 | B |
| 1 | A |
| 2 | B |
| 2 | B |
| 2 | B |
| 3 | B |
| 3 | B |
| 3 | A |
I want to add a column with a DAX expression which recategorises the Users based if any row is category A such that the results should look like this:
| User | Category | Recategorised |
| 1 | A | A |
| 1 | B | A |
| 1 | B | A |
| 1 | A | A |
| 2 | B | B |
| 2 | B | B |
| 2 | B | B |
| 3 | B | A |
| 3 | B | A |
| 3 | A | A |
This looks like it should be a simple expression but I haven't been able to work it out so far.
Thanks
hi, MaxwellB
try below code for columnColumn = var category_value = CALCULATETABLE(VALUES('Table (2)'[Category]),ALL('Table (2)'[Category])) RETURN IF("A" in category_value,"A",'Table (2)'[Category])If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Dangar332Resident Rockstar
hi, MaxwellB
try below code for columnColumn = var category_value = CALCULATETABLE(VALUES('Table (2)'[Category]),ALL('Table (2)'[Category])) RETURN IF("A" in category_value,"A",'Table (2)'[Category])If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- MaxwellBNew Member
Amazing thank you! 😊