cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
changezshafiq
New Member

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 4
FreemanZ
Community Champion
Community Champion

hi @changezshafiq 

ADDCOLUMNS returns a table, so comes the error. 

 

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

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:

 

changezshafiq_0-1676997450545.png

 

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

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?

I do not intend to create a virtual table, I just needed to insert new columns in sales table with different time measure shown below. I would then use these metrics and map them to Category, Geography, etc for my dashboard.

 

changezshafiq_0-1676999033981.png

 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors