Forum Discussion

rmorris's avatar
rmorris
Frequent Visitor
4 years ago
Solved

Equivalent of Excel SUMIFS between two tables

Hi,

 

New to PowerBI so a steep learning curve, but how to i acheive the following. (i didnt design tables, legacy from previous team)

 

Table 1, contains the Job#, Line# and the Type of job that it is.

 

Job# Line#Type
C4662 1C
C4662 2W
C4662 3C
C4662 4I
C4662 5C
C5000 1C

 

Table 2, contains the Job# and Line# but  details the time spent on each line.

 

Job# Line#Time Spent
C4662 11.5
C4662 23.5
C4662 36.2
C4662 40.7
C4662 51.2
C5000 110.2

 

I have a third table that is a summary table where i need to add three columns that will show the sum of time spent by each line type. This is what the end results needs to look like. Do i add these as new columns, or a measure, and what function do i use to achieve it?

Job# Type C TimeType I TimeType W Time
C4662 8.90.73.5
C5000 10.20.00.0

 

 

Job# is the only current relationship between tables

 

Thank you

  • rmorris For SUMIF you can use SUMX(FILTER(),...) or CALCULATE like:

    Type C Time Column =
      VAR __Job = [Job#]
      VAR __Lines = SELEECTCOLUMNS(FILTER('Table1',[Job#] = __Job && [Type] = "C"),"__Line",[Line#])
    RETURN
      SUMX(FILTER('Table2',[Job#] = __Job && [Line#] IN __Lines),[Time Spent])

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    rmorris For SUMIF you can use SUMX(FILTER(),...) or CALCULATE like:

    Type C Time Column =
      VAR __Job = [Job#]
      VAR __Lines = SELEECTCOLUMNS(FILTER('Table1',[Job#] = __Job && [Type] = "C"),"__Line",[Line#])
    RETURN
      SUMX(FILTER('Table2',[Job#] = __Job && [Line#] IN __Lines),[Time Spent])
    • rmorris's avatar
      rmorris
      Frequent Visitor

      Thank you so much, worked a treat!