Forum Discussion

changezshafiq's avatar
changezshafiq
New Member
3 years ago

Help with Add columns across two tables

Hello,

 

I am having an issue with adding multiple columns across two table which are connected through "Date" field. First table hosts item sales data, while second table has "Dates" spanned across weeks. When I create a new measure to insert new columns in first sales sales data table, I get the following error: "

T_VALUE =
 ADDCOLUMNS(tbl_DATE
               , "POS UNITS SOLD" , SUMX(RELATEDTABLE(tbl_POS), [POS Units])
               , "POS DOLLARS SOLD" , SUMX(RELATEDTABLE(tbl_POS), [POS Dollars])
               )
"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value".
 
Any help would be much appreciated.
 
Thanks!
 
 

4 Replies

  • hi changezshafiq 

    ADDCOLUMNS returns a table, so comes the error. 

     

    What do you plan to do further with the virtual table?

    • changezshafiq's avatar
      changezshafiq
      New Member

      Hi,

      I need to use these calculations to determine Last Week sales, Last 4 Week sales, Last 13 Week sales by referencing the Week Ending Date and LW Date in the date table which looks like below:

       

       

      so I want to create additional measure such as

      LW Unit Sales = CALCULATE([POS UNITS SOLD],tbl_Date[Week Ending]=tbl_Date[X LW])

      L4W Unit Sales = CALCULATE([POS UNITS SOLD,tbl_Date[Week Ending]>tbl_Date[X L4W],tbl_Date[Week Ending]<=tbl_Date[X LW])
      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        Hi changezshafiq 
        What FreemanZ means is what are you using the ADDCOLUMNS table for? Why do you need to have both Units Sold and Dollars Sold in one virtual table?