Search code examples
exceldaxpowerpivot

DAX returning value based on SUM of multiple rows in other table


Good evening all!!

Here's a fun one. I've been pouring through some other posts and it feels like there are many permutations of this scenario but none that span tables, so I'm looking for some input.

Consider the following:

Table A has two fields: ID and TYPE. TYPE will be our value to populate.

ID Type
1
2
3

Table B has two fields: ASSOCIATED ID and HOURS.

Associated ID Hours
1 24
1 0
2 10
2 38
3 50
3 25

The requirement is to return a value of "LESS THAN 25" or "GREATER THAN 25" for TYPE in TABLE A based on the SUM of the HOURS in TABLE B for the ASSOCIATED ID. Ex: ASSOCIATED ID "1" in TABLE has value 24 and 0 for a sum of 24, returning "LESS THAN 25" for TYPE in item ID 1 in TABLE A.

Any and all suggestions will be attempted, thank you so much to the community for taking a look.


Solution

  • Make sure you have a relationship between the two tables by using the ID. Then enter this formula into a column in the ID table:

    Type:=if(calculate(sum(TableB[Hours]))>25,"25 or More","Less than 25")
    

    enter image description here

    enter image description here