Forum Discussion

TDERUSSO's avatar
TDERUSSO
Frequent Visitor
9 years ago
Solved

How to create a new category based on a column?

I am try to create a new category column based on another column in my data model.  Below is an example of what I am try to accomplish.  Please let me know.

 

Column Data: Shirts, Sweaters, Jeans, Shorts --> New Category: Clothes

Column Data: Sneakers, Boots, Sandals, Slippers --> New Category: Shoes

 

Thanks,

Tony

  • Hi TDERUSSO

     

    Here is a quick and easy approach in DAX.  Just add a calculated column to your table (replace Table2[Column1] with your details.

     

    Category Column = SWITCH(
                    TRUE(), 
                    Table2[Column1] In {"Shirts","Sweaters","Jeans","Shorts"},"Clothes",
                    Table2[Column1] In {"Sneakers","Boots","Sandals","Slippers"},"Shoes",
                    "Other"
                    ) 

6 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi TDERUSSO

     

    Here is a quick and easy approach in DAX.  Just add a calculated column to your table (replace Table2[Column1] with your details.

     

    Category Column = SWITCH(
                    TRUE(), 
                    Table2[Column1] In {"Shirts","Sweaters","Jeans","Shorts"},"Clothes",
                    Table2[Column1] In {"Sneakers","Boots","Sandals","Slippers"},"Shoes",
                    "Other"
                    ) 
      • Phil_Seamark's avatar
        Phil_Seamark
        Icon for Microsoft Employee rankMicrosoft Employee

        Another option is to create a Group.

         

        From the Fields menu, click the elipsis next to the column you'd like to create groups for and click the "New Group" option at the bottom to bring up a window where you can build custom groups.

         

    • TDERUSSO's avatar
      TDERUSSO
      Frequent Visitor

      That worked, thanks for your help!

  • Hey TDERUSSO

     

    Have you thought about creating a sperate table that had the categories and then connecting them with a 1:many relationship?

    • TDERUSSO's avatar
      TDERUSSO
      Frequent Visitor

      Hi goaltender36, No, I'm new to Power BI.  Is that the best approach to handle this?