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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
Zubair_Muhammad
Community Champion
Community Champion

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
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

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
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Thank you very much!

 

I always apreciate an elegant solution. 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors