Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
perryadams
New Member

Create Multiple Calculated Columns in Transform or DAX at once

Hello,

I am trying to do a loop in Power BI since I have a dataset with multiple categories. Each category has it's own set of columns. In this example, there are categories A, B, and C, and each category has a numerator and denominator column. I would like to create a column in transform or DAX for each cateogry that calculates the ratio. In reality there are 20 categories and I have multiple calculated columns for each category I need to create. I am trying to reduce the manual steps needed. Below is an example of the table I'm trying to create without having to manually make 3 columns. Thanks!

perryadams_0-1704992515701.png

 

1 ACCEPTED SOLUTION
Corey_M
Resolver II
Resolver II

Sounds more like a data format issue than anything else, you can get it into a form that is much easier to calculate on by following these steps in Power Query

 

Step 1: Unpivot

Corey_M_0-1704995285460.png

Step 2  Split the Attribute

Corey_M_1-1704995347493.png

Step 3: Repivot by Attribute.1 

Corey_M_2-1704995512096.png

Step 4: add your division column

Corey_M_3-1704995615284.png

Corey_M_4-1704995648464.png

 

yeah it might have been faster to do it manuall lol, hope this helped

View solution in original post

3 REPLIES 3
perryadams
New Member

Thanks! Makes sense that an unpivoted data structure would make measure creation much simpler. Do you know what the tradeoffs would be in performance? If I have 20 categories, in the current format I'd need 20 measures. If the data was unpivoted, the number of rows would increase by 20x but only 1 measure would be needed

tbh, I'm not really the person to ask about performance, I've never really run into issues where power Bi took more than a second to load or update a visual to have to try and optimize performance

Corey_M
Resolver II
Resolver II

Sounds more like a data format issue than anything else, you can get it into a form that is much easier to calculate on by following these steps in Power Query

 

Step 1: Unpivot

Corey_M_0-1704995285460.png

Step 2  Split the Attribute

Corey_M_1-1704995347493.png

Step 3: Repivot by Attribute.1 

Corey_M_2-1704995512096.png

Step 4: add your division column

Corey_M_3-1704995615284.png

Corey_M_4-1704995648464.png

 

yeah it might have been faster to do it manuall lol, hope this helped

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.