Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
))
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 66 | |
| 44 | |
| 40 | |
| 29 | |
| 19 |
| User | Count |
|---|---|
| 200 | |
| 126 | |
| 103 | |
| 70 | |
| 53 |