Forum Discussion

NHW's avatar
NHW
New Member
3 years ago

Unable to figure out the difference in the code.

Hi, I am unable to figure out why I cannot replicate the result in the above table. The difference lies in the results under the verdict legend. 

 

 

This is the related power query m code for the above table:

#"Added Conditional Column" = Table.AddColumn(#"Renamed Columns2", "Verdict Score", each if [#"Overall Verdict "] = "IN" then 0 else if [#"Overall Verdict "] = "JI" then 0.5 else if [#"Overall Verdict "] = "OUT" then 3 else null, type number),
#"Replaced Value1" = Table.ReplaceValue(#"Added Conditional Column","Out","OUT",Replacer.ReplaceText,{"Overall Verdict "}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","In","IN",Replacer.ReplaceText,{"Overall Verdict "}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","Just In","JI",Replacer.ReplaceText,{"Overall Verdict "}),
#"Replaced Value4" = Table.ReplaceValue(#"Replaced Value3","Just IN","JI",Replacer.ReplaceText,{"Overall Verdict "}),
#"Removed Columns3" = Table.RemoveColumns(#"Replaced Value4",{"Verdict Score"}),
#"Added Conditional Column1" = Table.AddColumn(#"Removed Columns3", "Custom", each if [#"Overall Verdict "] = "IN" then 0 else if [#"Overall Verdict "] = "OUT" then 3 else if [#"Overall Verdict "] = "JI" then 0.5 else null, type number),
#"Renamed Columns3" = Table.RenameColumns(#"Added Conditional Column1",{{"Custom", "Verdict Score"}}),

 

This is the related power query M code for the bottom table: 

#"Added Conditional Column" = Table.AddColumn(#"Renamed Columns", "Verdict Score", each if [#"Overall Verdict "] = "IN" then 0 else if [#"Overall Verdict "] = "Just IN" then 0.5 else if [#"Overall Verdict "] = "OUT" then 3 else null),

#"Replaced Value" = Table.ReplaceValue(#"Removed Columns","JI","Just In",Replacer.ReplaceText,{"Overall Verdict "}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Out","OUT",Replacer.ReplaceText,{"Overall Verdict "}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","In","IN",Replacer.ReplaceText,{"Overall Verdict "}),

2 Replies

  • NHW Please try below code, i hope this hepls you!

    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","JI","Just In",Replacer.ReplaceText,{"Overall Verdict "}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Out","OUT",Replacer.ReplaceText,{"Overall Verdict "}),
    #"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","In","IN",Replacer.ReplaceText,{"Overall Verdict "}),
    #"Added Conditional Column" = Table.AddColumn(#"Replaced Value3", "Verdict Score", each if [#"Overall Verdict "] = "IN" then 0 else if [#"Overall Verdict "] = "Just IN" then 0.5 else if [#"Overall Verdict "] = "OUT" then 3 else null)

    • NHW's avatar
      NHW
      New Member

      Hi, isn't the below code that you have provided to help the same as the code I am using currently?

      Here is a better example of the issue: