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.
Very new to Power BI here.
I want to create a new column that is a bit of a flag based on other columns
where Column A Contains "Info A", insert "Info A" in new column AND
where Column A Contains "Info B", insert "Info B" in new Column AND
Where Column B = "Type 1", Insert "Info" in new column AND
Where Column C = "Type 1" AND Column B <> "Type 1", Insert "Info" into new column
where it does not meet any of this criteria, leave blank
So I end up with a column that has flagged certain rows if they meet this criteria.
Would I do a calculated column here, or create a new column - and what would the DAX be?
Thanks in advance!
Solved! Go to Solution.
Hi @Swiftojo , a calculated column would be a good option here. The DAX SWITCH function would be a perfect candidate for your use case. How a SWITCH function works is it evaluates multiple conditions and returns a value based on the condition met. This is similar to using nested IF statements, however it can reduce query complexity and make it much more readible.
Here is an example DAX for your use case:
Column =
SWITCH(
TRUE(),
CONTAINSSTRING('TableName'[Column A], "Info A"), "Info A",
CONTAINSSTRING('TableName'[Column A], "Info B"), "Info B",
'TableName'[Column B] = "Type 1", "Info",
'TableName'[Column C] = "Type 1" && 'TableName'[Column B] <> "Type 1", "Info",
BLANK()
)
If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,
Samson
Hi @Swiftojo,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Thank you everyone. This solution worked!
Hi @Swiftojo,
Thank you for reaching out to the Microsoft Fabric Community Forum.
I’ve reproduced your scenario in Power BI Desktop based on the logic you provided. I created sample data and implemented a calculated column using DAX to flag rows according to the specified conditions.
I’ve validated the logic and received the expected output, matching your requirements:
The DAX used for the calculated column:
Flag =
SWITCH(TRUE(),
CONTAINSSTRING([Column A], "Info A"), "Info A",
CONTAINSSTRING([Column A], "Info B"), "Info B",
[Column B] = "Type 1", "Info",
[Column C] = "Type 1" && [Column B] <> "Type 1", "Info",
BLANK()
)
For your convenience, I’ve attached the .pbix file used for testing this scenario. Feel free to explore and modify it further as per your dataset.
Thanks @kushanNa & @SamsonTruong for sharing your valuable insights.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @Swiftojo
you can use the calculated column
try using following code ?
Flag =
SWITCH(TRUE(),
CONTAINSSTRING([Column A], "Info A"), "Info A",
CONTAINSSTRING([Column A], "Info B"), "Info B",
[Column B] = "Type 1", "Info",
[Column C] = "Type 1" && [Column B] <> "Type 1", "Info",
BLANK()
)
eg:
Hi @Swiftojo , a calculated column would be a good option here. The DAX SWITCH function would be a perfect candidate for your use case. How a SWITCH function works is it evaluates multiple conditions and returns a value based on the condition met. This is similar to using nested IF statements, however it can reduce query complexity and make it much more readible.
Here is an example DAX for your use case:
Column =
SWITCH(
TRUE(),
CONTAINSSTRING('TableName'[Column A], "Info A"), "Info A",
CONTAINSSTRING('TableName'[Column A], "Info B"), "Info B",
'TableName'[Column B] = "Type 1", "Info",
'TableName'[Column C] = "Type 1" && 'TableName'[Column B] <> "Type 1", "Info",
BLANK()
)
If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,
Samson
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 |
---|---|
76 | |
74 | |
57 | |
39 | |
33 |
User | Count |
---|---|
71 | |
66 | |
57 | |
49 | |
47 |