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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Milagros
Helper I
Helper I

Missing Columns

Hi there, I have a table of 12 or so columns of numeric and text data, I applied a number of steps and then finally added a column using this m code "RAG = Table.AddColumn(#"Reordered Columns", "Custom", each if [Target] = null or [Result] = null then null
else if [Polarity] = "Higher is better" and [Result] >= [Target] then 1
else if "Higher is better" and [Result] >= ([Target]*0.95) then 0
else if "Higher is better" then -1
else if [Polarity] = "Lower is better" and [Result] <= [Target] then 1
else if "Lower is better" and [Result] <= ([Target]*1.05) then 0
else if "Lower is better" then -1
else null)"

I applied the query and when I looked in Data view the only object I could see was the m code.  Has the added column somehow hidded the other columns?    

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @Milagros ,

 

Very difficult to diagnose based on the info provided.

Could you share a couple of screenshots of what your PQ step list looks like, and what it looks like in the Data View please?

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

Anonymous
Not applicable

Just get rid of the first and last quotes (")

 

--Nate

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Milagros 

 

Did you put the it with the quotes in Advanced Editor? If yes, like @Anonymous  said, you need to get rid of " ", and you also missed some [Polarity] =

RAG
  = Table.AddColumn(
    #"Reordered Columns",
    "Custom",
    each
      if [Target] = null or [Result] = null then
        null
      else if [Polarity] = "Higher is better" and [Result] >= [Target] then
        1
      else if [Polarity] = "Higher is better" and [Result] >= ([Target] * 0.95) then
        0
      else if [Polarity] ="Higher is better" then
        - 1
      else if [Polarity] = "Lower is better" and [Result] <= [Target] then
        1
      else if [Polarity] ="Lower is better" and [Result] <= ([Target] * 1.05) then
        0
      else if [Polarity] ="Lower is better" then
        - 1
      else
        null
  )

 Probably can try it

RAG
  = Table.AddColumn(
    #"Reordered Columns",
    "Custom",
    each
      if [Target] = null or [Result] = null then
        null
      else if ([Polarity] = "Higher is better" and [Result] >= [Target])
        or ([Polarity] = "Lower is better" and [Result] <= [Target])
      then
        1
      else if ([Polarity] = "Higher is better" and [Result] >= [Target] * 0.95)
        or ([Polarity] = "Lower is better" and [Result] <= [Target] * 1.05)
      then
        0
      else if [Polarity] = "Higher is better" or [Polarity] = "Lower is better" then
        - 1
      else
        null
  )

Hi Vera, Thank you so much, that seems to work perfectly!

 

Mila

Anonymous
Not applicable

Just get rid of the first and last quotes (")

 

--Nate

Thanks Nate, Much appreciated.

 

Mila

BA_Pete
Super User
Super User

Hi @Milagros ,

 

Very difficult to diagnose based on the info provided.

Could you share a couple of screenshots of what your PQ step list looks like, and what it looks like in the Data View please?

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.