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 would like to replicate the similar conditional column in Power Query, How should I do it?
IF(
Attribute("Spend Category") !=null
&& Attribute("Spend Category").Substring(0,2).In(
[
"ZZ"
]
),
"No",
"Yes"
)
Thank you
Solved! Go to Solution.
@alice11987 Try the following:
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([Spend Category], "ZZ") and Spend Category] <> null then "No" else "Yes")
where "#Changed Type" should be changed to the appropraite names that your data preparation step is using.
@alice11987 What are you wanting to acheive in English? I'm not familiar with the code you've posted, but if I understand it correctly I agree with @johnyip
In Power Query, click Add Column > Custom Column , and then paste this code:
if Text.Contains(Text.Start([Spend Category], 2), "ZZ") and [Spend Category] <> null then "No" else "Yes"
If you have a list of other things that you need to include (not just "ZZ"), then try:
if List.Contains( {"ZZ", "DD"}, Text.Start([Spend Category], 2)) and [Spend Category] <> null then "No" else "Yes"
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@alice11987 Try the following:
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([Spend Category], "ZZ") and Spend Category] <> null then "No" else "Yes")
where "#Changed Type" should be changed to the appropraite names that your data preparation step is using.
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.
| User | Count |
|---|---|
| 57 | |
| 40 | |
| 36 | |
| 18 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 67 | |
| 38 | |
| 34 | |
| 23 |