Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello everyone,
I have a question as to how to create a new calculcated column, based on the values of 2 columns. I'm really new to PowerBI, and to posting on this forum, so I don't know how to attach a sample dataset. I'll try to describe as best as possible.
I have 2 columns, one is Incident Type Group, and the other is Incident Type Code. There are many values for Incident Type code, and I condense it into a group depending on what number the code starts with. If the code started with a 1, it belonged to the 'Fire' group, if it started with a 3, it belonged to the 'EMS' group. Please see 'Incident Group' for more info.
Incident Group | Incident Code |
1 - Fire | 13 |
2 - Overpressure | 130 |
3 - EMS | 131 |
4 - Hazmat | 132 |
5 - Service | 133 |
6 - Good Intent | 134 |
7 - False | 135 |
8 - Severe Weather | 136 |
9 - Special Incident | 137 |
138 | |
322 | |
323 | |
324 | |
352 |
I would like to create a new column, named 'Monthly Incident Type', where I take into consideration the specific values above in the Incident Code.
If Incident Code is in ['13','130','131','132','133','134','135','136','137', '138'] then it equals 'Vehicle Fire'
If Incident Code is in ['322','323','324','352'] then it equals 'Vehicle Accident'
else, if Incident Code starts with 1, then 'Fire',
2, then 'Overpressure',
3, then 'EMS',
4, then 'Hazamt' and so on based on the Incident Group. Both Incident Group and Incident Code columns are type Text.
Would anyone know how to approach this?
Thank you for the help,
Denisse
@Anonymous ,
I didn't get the second block for the if, but with this code you can create another column if necessary:
Monthly Incident Type =
IF( 'Table (2)'[Incident Code] in {13, 130, 131, 132, 133,134,135,136,137,138}, "Vehicle Fire",
IF('Table (2)'[Incident Code] in {322, 323, 324,352}, "Vehicle Accident",
IF( MID('Table (2)'[Incident Code], 1, 1) = "1", "Fire",
IF(MID('Table (2)'[Incident Code], 1, 1) = "2", "OverPressure",
IF(MID('Table (2)'[Incident Code], 1, 1) = "3", "EMS",
IF(MID('Table (2)'[Incident Code], 1, 1)= "4", "Hazamt"))))))
This block gets the first number and can be used for the others values:
MID('Table (2)'[Incident Code], 1, 1
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |