Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

What is the "Document" argument doing here?

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

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

An example is probably best here.

 

Say we have this table:

AlexisOlson_0-1652203718102.png

Applying the given logic results in:

AlexisOlson_1-1652203752944.png

 

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).

View solution in original post

5 REPLIES 5
AlexisOlson
Super User
Super User

An example is probably best here.

 

Say we have this table:

AlexisOlson_0-1652203718102.png

Applying the given logic results in:

AlexisOlson_1-1652203752944.png

 

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).

Anonymous
Not applicable

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

Anonymous
Not applicable

But to answer your question you're replacing the result of the if statement with the text "Document", in the column named "Value".

 

--Nate

Anonymous
Not applicable

Yes, The F statement is complete without the "Document", But the Table.ReplaceValue is not complete without it.

 

  • But are you just trying to make a conditional column, as opposed to replacing a value? Seems like you could write just the if statement in an AddColumn function and be done with it.

--Nate

Anonymous
Not applicable

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

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.