Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I came across the below m code in a power bi report but struggling to work out what the "Document" argument in the attached m code is actually doing..
Table.ReplaceValue(#"Filtered Rows",
each if [Type] = "Document Check" or [Type] = "Publishing Check" then "OK"
else "DO NOT REPLACE",
"Document",
Replacer.ReplaceValue,{"Value"})
If I remove the "Document" argument from the code it says function requires 5 arguments and only received 4.
The If statement seems complete without the "Document" argument however so hoping someone can explain what thsi is doing?
Thanks,
Bobby
Solved! Go to Solution.
An example is probably best here.
Say we have this table:
Applying the given logic results in:
For the Table.ReplaceValue function, the second argument is the old value we want to replace and the third value ("Document") is the value we want to replace the old value with.
The if-condition you have means that the second argument will always be either "OK" or "DO NOT REPLACE". So the step either attempts to replace "OK" with "Document" or "DO NOT REPLACE" with "Document" (depending on whether the if-condition is true or false).
An example is probably best here.
Say we have this table:
Applying the given logic results in:
For the Table.ReplaceValue function, the second argument is the old value we want to replace and the third value ("Document") is the value we want to replace the old value with.
The if-condition you have means that the second argument will always be either "OK" or "DO NOT REPLACE". So the step either attempts to replace "OK" with "Document" or "DO NOT REPLACE" with "Document" (depending on whether the if-condition is true or false).
Thats great thankyou.. I did get to the same reasoning aswell.. eventually. I think the way the syntax is read its easy to confuse what is replacing what until you really separate the constituent part of the table.replacevalues arguments.
Thanks again.
Bobby
But to answer your question you're replacing the result of the if statement with the text "Document", in the column named "Value".
--Nate
Yes, The F statement is complete without the "Document", But the Table.ReplaceValue is not complete without it.
--Nate
Thanks for the quick reply.
I didnt write this code just trying to decipher it.
Yeah so if the "Document" poart is need for the replacevalue function that implies the identified values will be rplaced with the value "Document"?
and this part is not replacing any values..
each if [Type] = "Document Check" or [Type] = "Publishing Check" then "OK"
else "DO NOT REPLACE",
Its just identifying if [Type] = "Document CHECK" or "Publishing Check" then replace with "Document"? but then what is the .. then "OK" else "DO NOt Replace" part doing?
Thanks,
Bobby
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 6 | |
| 5 | |
| 3 |