We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 38 | |
| 33 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 38 | |
| 34 | |
| 22 |