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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
NHW
New Member

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. 

NHW_0-1690880630009.png

 

 

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 2
Mahesh0016
Super User
Super User

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

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:

NHW_0-1691026494579.png

 



Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors