cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JANDREASL Frequent Visitor
Frequent Visitor

Calc. Col in table1 = Sum all val in table2.a if table2.b = "10" and table2.c=table1.c

As the title describes it, I would like to create a calculated column in table 1 populated with data from table 2.

 

Logic

If OrdNo in table 1 = OrdNo in table 2 AND WageSrt in table 2 = "10" SUM all instances of NoFin in table 2 and store in table 1 in new column in corresponding OrdNo.

Or

Calc. Col in table1 = Sum all val in table2.a if table2.b = "10" and table2.c=table1.c

 

Structure

Table 1

OrdNo calculated column

7528        10

7230        8

 

Table 2

OrdNo NoFin WageSrt

7528        6         10

7528        5          0

7528        4          10

7230        8          10

 

I thought of the following but the expression gives multiple columns error:

Actual_Work_hours =
CALCULATE(
SUMX('VB OrdLn';'VB OrdLn'[NoFin]);
'VB OrdLn'[WageSrt]="10";
'VB OrdLn'[OrdNo]='VB Ord'[OrdNo]
)
Or
Actual_Work_hours =
CALCULATE(
SUM('VB OrdLn'[NoFin]);
'VB OrdLn'[WageSrt]="10";
'VB OrdLn'[OrdNo]='VB Ord'[OrdNo]
)
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Calc. Col in table1 = Sum all val in table2.a if table2.b = "10" and table2.c=table1.c

Hi
Try with

Actual_Work_hours =
Var myord='VB Ord'[OrdNo]
Return
CALCULATE(
SUM('VB OrdLn'[NoFin]);
'VB OrdLn'[WageSrt]="10";
'VB OrdLn'[OrdNo]=MYORD
)
2 REPLIES 2
Super User
Super User

Re: Calc. Col in table1 = Sum all val in table2.a if table2.b = "10" and table2.c=table1.c

Hi
Try with

Actual_Work_hours =
Var myord='VB Ord'[OrdNo]
Return
CALCULATE(
SUM('VB OrdLn'[NoFin]);
'VB OrdLn'[WageSrt]="10";
'VB OrdLn'[OrdNo]=MYORD
)
JANDREASL Frequent Visitor
Frequent Visitor

Re: Calc. Col in table1 = Sum all val in table2.a if table2.b = "10" and table2.c=table1.c

Thank you very much!

 

I always apreciate an elegant solution. :-)