0
votes

Use first two digits of Column to give a name to a new column.

I have a list of companies and their NAICS ID. I would like to filter these into a pie chart but I don't want the 90000 different names (just the general ex. Agriculture or Mining). I want to utilize the first two digits in for the column to identify its general name. I am trying to use the DAX expression Switch to get this started. Is there a filter to do this within PowerBI?

I haven't started yet since I am not sure if this is possible.

1

1 Answers

0
votes

You could simply create a calculated column based off of the original NAICS code using the following:

FirstTwoDigitsOfNAICS :=
SWITCH (
    TRUE (),
    LEFT ( 'Table'[NAICSCode] ) = x, "Something",
    LEFT ( 'Table'[NAICSCode] ) = y, "Something Else"
)

This DAX will simply pull the first two characters from the entire code.