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

Join 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.

Reply
kjartank
Helper II
Helper II

Calculating column with more than one IF statement

Hi there.

 

I basically have a column that consists of numbers from 1 to 8. I want to calculate a column with a 100 scale, where 8 is left blank.

1 = 100,

2 = 83,33,

3 = 66,66,

4 = 50,

5 = 33,33,

6 = 16,66

7 = 0

8 = null

I've tried to add a custom column, but am not sure of how to write the formula with 8 if statements.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @kjartank,

 

I think you also copy the "calculate column:" to your formula, right?
It means below formula is a calculate column, you don't need to copy it into the formula.

Result = SWITCH([Column],1,"100",2,"83,33",3,"66,66",4,"50",5,"33,33",6,"16,66",7,"0",8,BLANK(),BLANK()) 

 

Regards,

XIaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @kjartank,

 

I think switch function will be suitable, but if you result contains multiple result, it can only return as text format.

Calculate column:
Result = SWITCH([Column],1,"100",2,"83,33",3,"66,66",4,"50",5,"33,33",6,"16,66",7,"0",8,BLANK(),BLANK())

 

If you want to know how to split it and got the specified value, you can refer to below link:

DAX: How to Split (left) a text column on Character (space)?

 

Regards,

Xiaoxin Sheng

hi @Anonymous

 

I've hopefully been trying to use that bit of code, but it states "Expressions that yield variant data-type cannot be used to define calculated columns." So unfortunately, it won't work.

Anonymous
Not applicable

Hi @kjartank,

 

I think you also copy the "calculate column:" to your formula, right?
It means below formula is a calculate column, you don't need to copy it into the formula.

Result = SWITCH([Column],1,"100",2,"83,33",3,"66,66",4,"50",5,"33,33",6,"16,66",7,"0",8,BLANK(),BLANK()) 

 

Regards,

XIaoxin Sheng

I had the formatting wrong. This will be so extremely useful, as I have lots of data that needs to be transformed.

Thanks a lot! 🙂

sokg
Solution Supplier
Solution Supplier

try this

 

New column = SWITCH(TRUE();

                               TABLE[COLUMN WHERE 1...8 LIVES]=1;100;

                               TABLE[COLUMN WHERE 1...8 LIVES]=2;83.33;

                               TABLE[COLUMN WHERE 1...8 LIVES]=3;66.66;

                               TABLE[COLUMN WHERE 1...8 LIVES]=4;50;

                               TABLE[COLUMN WHERE 1...8 LIVES]=5;33.33;

                               TABLE[COLUMN WHERE 1...8 LIVES]=6;16.66;

                               TABLE[COLUMN WHERE 1...8 LIVES]=7;0;

                               BLANK()

                               )

I  suppose that 1..8 are numbers.

 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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