This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hi I am trying to create a custom column based on logic if sce_udfc is not blank then use the same value in new column else use the Course Code and assign the value to new column. i have created this code but getting error as "Expression.Error: The name 'IF' wasn't recognized. Make sure it's spelled correctly."
IF(
NOT(ISBLANK([sce_udfc])),
[sce_udfc],
SWITCH(
[crs_code],
"BAS4WWCF3NWP", 5130,
"MAS3CCTH1NWP", 1700,
"MAS1EDON1NWF", 5100,
"MCS1PRPT1NWP", 1700,
"MCS1EDEC1NWP", 1700,
"RPS6EDUC1NWP", 2050,
))
Solved! Go to Solution.
Please try this for the new column
newcolumn =
IF (
NOT ( ISBLANK ( [sce_udfc] ) ),
[sce_udfc],
SWITCH (
[crs_code],
"BAS4WWCF3NWP", "5130",
"MAS3CCTH1NWP", "1700",
"MAS1EDON1NWF", "5100",
"MCS1PRPT1NWP", "1700",
"MCS1EDEC1NWP", "1700",
"RPS6EDUC1NWP", "2050"
)
)
"Expressions that yield variant data-type cannot be used to define calculated columns" error occurs when it detects multiple data-types are returned in a calculated column formula. In original formula, [sce_udfc] column is of Text data type while the numbers (5130, 1700...) in SWITCH function are of whole number data type, so it leads to this error. To fix it, you can convert the numbers into Text data type by putting the numbers in double quotes.
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
Hi @miTutorials Thanks for your prompt response, now i am getting error as "Expressions that yield variant data-type cannot be used to define calculated columns"
Both column is of Text Data Type
Please try this for the new column
newcolumn =
IF (
NOT ( ISBLANK ( [sce_udfc] ) ),
[sce_udfc],
SWITCH (
[crs_code],
"BAS4WWCF3NWP", "5130",
"MAS3CCTH1NWP", "1700",
"MAS1EDON1NWF", "5100",
"MCS1PRPT1NWP", "1700",
"MCS1EDEC1NWP", "1700",
"RPS6EDUC1NWP", "2050"
)
)
"Expressions that yield variant data-type cannot be used to define calculated columns" error occurs when it detects multiple data-types are returned in a calculated column formula. In original formula, [sce_udfc] column is of Text data type while the numbers (5130, 1700...) in SWITCH function are of whole number data type, so it leads to this error. To fix it, you can convert the numbers into Text data type by putting the numbers in double quotes.
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
Can you share sample pbix ?
I have checked the below and it is working, please test. Right click on the table and choose NewColumn.
Column = IF(
NOT(ISBLANK([Test])),
[Test],
SWITCH(
[Check],
"BAS4WWCF3NWP", 5130,
"MAS3CCTH1NWP", 1700,
"MAS1EDON1NWF", 5100,
"MCS1PRPT1NWP", 1700,
"MCS1EDEC1NWP", 1700,
"RPS6EDUC1NWP", 2050
))
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 31 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 66 | |
| 56 | |
| 31 | |
| 26 | |
| 23 |