Forum Discussion

MaxwellB's avatar
MaxwellB
New Member
2 years ago
Solved

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:

 

UserCategory
1A
1B
1B
1A
2B
2B
2B
3B
3B
3A

 

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:

 

UserCategoryRecategorised
1AA
1BA
1BA
1AA
2BB
2BB
2BB
3BA
3BA
3AA

 

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 column 

    Column = 
    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

  • Dangar332's avatar
    Dangar332
    Resident Rockstar

    hi, MaxwellB 

    try below code for column 

    Column = 
    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.