Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

ADDCOLUMNS issue

Hello - Trying to use the calculated column formula below and am getting this error message:
 
"This expression refers to mulitiple columns. Multiple columns cannot be converted to a scalar value."
 
My goal is to add the "Potential" column from my Forecast table, to my Shipped Orders table. (they are not directly connected via any relationships)
 
Add Potential = ADDCOLUMNS(
    'Flu_Shipped Orders',
    "Potential",
    VAR MonthNumber =
        MONTH ( 'Flu_Shipped Orders'[Date Shipped] )
    RETURN
        LOOKUPVALUE (
            Forecasts_Snapshots[Potential],
            Forecasts_Snapshots[Item],'Flu_Shipped Orders'[Item],
            Forecasts_Snapshots[Est.Close], MonthNumber))

 

 

  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous 

    Add Potential =
        VAR MonthNumber =
            MONTH ( 'Flu_Shipped Orders'[Date Shipped] )
        RETURN
            LOOKUPVALUE (
                Forecasts_Snapshots[Potential],
                Forecasts_Snapshots[Item],'Flu_Shipped Orders'[Item],
                Forecasts_Snapshots[Est.Close], MonthNumber)
  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous  addcolumns return a table not a column, you already have a table to which you are adding column. If you were creating a calculated table using DAX then yes, addcolumns would work.

     

    I would 💖 Kudos 🙂 if my solution helped. If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

7 Replies

  • Anonymous you just need the following expression

     

         LOOKUPVALUE (
                Forecasts_Snapshots[Potential],
                Forecasts_Snapshots[Item],'Flu_Shipped Orders'[Item],
                Forecasts_Snapshots[Est.Close], MonthNumber))
     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      parry2k    I'm not clear on your solution.     This seems to be the same formula I have already.  

       

      I tried it as a standalone formula  (just using the lookupvalue), but it does not recognize "monthnumber"    (that was a VAR from the original formula) 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Just a quick update....changing the "monthnumber" to the actual value, also gives me the same error.    "A table of multiple values was supplied where a single value was expected"

       

      I don't get it because the code seems correct.  

       

       

      Lookup = LOOKUPVALUE (
                  Forecasts_Snapshots[Potential],
                  Forecasts_Snapshots[Item],'Flu_Shipped Orders'[Item],
                  Forecasts_Snapshots[Est.Close],'Flu_Shipped Orders'[Date Shipped])
      • parry2k's avatar
        parry2k
        Super User

        Anonymous 

        Add Potential =
            VAR MonthNumber =
                MONTH ( 'Flu_Shipped Orders'[Date Shipped] )
            RETURN
                LOOKUPVALUE (
                    Forecasts_Snapshots[Potential],
                    Forecasts_Snapshots[Item],'Flu_Shipped Orders'[Item],
                    Forecasts_Snapshots[Est.Close], MonthNumber)
  • Anonymous's avatar
    Anonymous
    Not applicable

    Also when working with calculated columns I find it rather useful to 'design' the formula in excel first. That way you get better error handling compared to Power BI Pro.