Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi
I have query with 3 columns: InvoiceNumber, InvoiceType and InvoiceAmount. There are 40K+ records, and half a dozen of them have the wrong InvoiceType (need to change com "Service" to "Product"
So, I put up this code:
replaceType =
if "InvNumber" = "30881" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "30769" and "InvType" = "Service" then Table.ReplaceValue(PreviousStep, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "30770" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "30771" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "30772" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "30791" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "31261" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "31262" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "31336" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else if "InvNumber" = "31337" and "InvType" = "Service" then Table.ReplaceValue(replaceCarga, "Service", "Product", Replacer.ReplaceText, {"InvType"})
else "InvType"="InvType"
in
replaceType
The thing is it is not working at all. I don't know how to instruct a "do nothing" in the last else. Any ideas?
Is this query a custom function or others? Which error occurs when you implement it?
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi
It's the standard replace value function from power query. The point is that I cannot make it work with if statements inside it.
I believe you can also create a quick table of replacements and then merge the 2 fields of both tables
InvNumber | InvType | Correct Replacement |
30881 | Service | Product |
30769 | Service | Product |
30770 | Service | Product |
Zubair, that seems to be the easier way to go, thanks for that. I'll use it, because in the end of the day, it solves the problem.
In the meantime I really wanted to improve my "IF" skills. This "do nothing' at the end of the if then else statement is really troublesome. Let's see if somebody come up with an insight on that.
Best regards,
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
118 | |
107 | |
69 | |
68 | |
43 |
User | Count |
---|---|
148 | |
104 | |
102 | |
89 | |
66 |