Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
Im trying to create a new column based on 3 queries? I basically want to say if it contains this then bring back that:
So if it contains 123 its Test1, 456 its Test 2 else Test 3
NewColumnName =
IF(
'NewColumnName'[SERVICE_TYPE] = 123,
"Test1",
IF(
'NewColumnName'[SERVICE_TYPE] = 456,
"Test2",
"Test3"
)
)
Thanks in advance
Solved! Go to Solution.
Try this:
NewColumnName =
IF(
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE], "123"),
"Test1",
IF(
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE],"456"),
"Test2",
"Test3"
)
)
Amazing, thank you!
You're welcome @dommyw277 🙂
I would also suggest you to use SWITCH instead of nested IFs:
NewColumnName =
SWITCH(TRUE(),
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE], "123"),"Test1",
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE],"456"),"Test2",
"Test3")
What is the type of the column SERVICE_TYPE? Is it Text or Numeric? If it is text you are treating it as a numeric.
Hi, yes its Text - it contains text and numbers?
Thanks. Heres a brief example:
cd6b6eec- Azure
0b4c205 - AZURE 2
Try this:
NewColumnName =
IF(
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE], "123"),
"Test1",
IF(
CONTAINSSTRING('NewColumnName'[SERVICE_TYPE],"456"),
"Test2",
"Test3"
)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
96 | |
69 | |
45 | |
39 | |
30 |
User | Count |
---|---|
155 | |
96 | |
60 | |
42 | |
41 |