Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hello All, I need some assistance with writing Nested If statement, I am trying to create a new column with the following if statement.
IF [Category] = "Martial Arts " THEN
IF [Sub Category] = "Boxing" THEN "Boxing "
ELSEIF [Sub Category] = "Karate" THEN "Karate"
END
ELSEIF [Category] = "Sports" THEN "Sports"
ELSEIF [Category] = "Winter Sports" THEN
IF [Sub Category] = "Snowboarding" THEN "Snowboarding"
ELSEIF [Sub Category] = "Skiing" THEN "Skiing"
END
I tried using Switch function and had no luck, does anyone has any suggestions?
Thank you
Solved! Go to Solution.
I think SWITCH is a good idea.
SWITCH (
TRUE (),
[Category] = "Martial Arts " && [Sub Category] = "Boxing", "Boxing",
[Category] = "Martial Arts " && [Sub Category] = "Karate", "Karate",
[Category] = "Sports", "Sports",
[Category] = "Winter Sports" && [Sub Category] = "Snowboarding", "Snowboarding",
[Category] = "Winter Sports" && [Sub Category] = "Skiing", "Skiing"
)
I think SWITCH is a good idea.
SWITCH (
TRUE (),
[Category] = "Martial Arts " && [Sub Category] = "Boxing", "Boxing",
[Category] = "Martial Arts " && [Sub Category] = "Karate", "Karate",
[Category] = "Sports", "Sports",
[Category] = "Winter Sports" && [Sub Category] = "Snowboarding", "Snowboarding",
[Category] = "Winter Sports" && [Sub Category] = "Skiing", "Skiing"
)
Hi @Anonymous ,
You can use below code:-
Measure =
IF (
[Category] = "Martial Arts ",
IF (
[Sub Category] = "Boxing",
"Boxing",
IF (
[Sub Category] = "Karate",
"Karate",
IF (
[Category] = "Sports",
"Sports",
IF (
[Category] = "Winter Sports",
IF (
[Sub Category] = "Snowboarding",
"Snowboarding",
IF ( [Sub Category] = "Skiing", "Skiing" )
)
)
)
)
)
)
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
5 |
User | Count |
---|---|
20 | |
14 | |
10 | |
9 | |
6 |