cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
STIBBS_807
Resolver I
Resolver I

Replace Value Based on Compound If Statement.

I am looking for help with my ReplaceValue statement.  I pull some code from other discussions but was unsucessful in getting the statement to work appropriatly.

 

Here is what I have:

 

 #"Replaced Value in Supervisor" = Table.ReplaceValue(Source, each [Supervisor],
each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then "Ralph"
else Replacer.ReplaceValue,{"Supervisor"})

 

I get this error:

Expression.Error: 4 arguments were passed to a function which expects 5.
Details:
Pattern=
Arguments=[List]

 

Eventually I want to get to this:

 

 #"Replaced Value in Supervisor"= Table.ReplaceValue(Source, each [Supervisor],

each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then if [Worker] = "Sue" then "Ralph"

else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then if [Worker] = "Anna" then "Stan" 

else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then if [Worker] = "Pete" then "George" 

else Replacer.ReplaceValue,{"Supervisor"})

2 ACCEPTED SOLUTIONS
STIBBS_807
Resolver I
Resolver I

Solved my issue:

 

= Table.ReplaceValue(Source,each [Supervisor],
each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Sue" then "Ralph"
else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Anna" then "Stan"
else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Pete" then "George"
else [Supervisor],Replacer.ReplaceValue,{"Supervisor"})

View solution in original post

CNENFRNL
Super User
Super User

= let sup = Record.FromList({"Ralph","Stan","George"}, {"Sue","Anna","Pete"}) in Table.ReplaceValue(Source, each [Supervisor], each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then Record.FieldOrDefault(sup, [Worker], [Supervisor]) else [Supervisor], Replacer.ReplaceValue, {"Supervisor"})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Super User
Super User

= let sup = Record.FromList({"Ralph","Stan","George"}, {"Sue","Anna","Pete"}) in Table.ReplaceValue(Source, each [Supervisor], each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" then Record.FieldOrDefault(sup, [Worker], [Supervisor]) else [Supervisor], Replacer.ReplaceValue, {"Supervisor"})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

STIBBS_807
Resolver I
Resolver I

Solved my issue:

 

= Table.ReplaceValue(Source,each [Supervisor],
each if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Sue" then "Ralph"
else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Anna" then "Stan"
else if [Supervisor]="Not Assigned/Non affecté Not Assigned/Non affecté" and [Worker]="Pete" then "George"
else [Supervisor],Replacer.ReplaceValue,{"Supervisor"})

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors