Forum Discussion
JimT99
2 years agoHelper I
Create Calculated Column using column value as variable in where clause
I want to create a calculated column in one table (call it TableA) that Calculates a value from another table (TableB) based on column value in TableA ProdMax = CALCULATE(MAX(TABLEB[Valu...
- 2 years ago
Try this:
ProdMax = VAR _Prod = TABLEA[PRODUCT] RETURN CALCULATE ( MAX ( TABLEB[Value] ), TABLEB[PRODUCT] = _Prod )Other variations:
ProdMax = CALCULATE ( MAX ( TABLEB[Value] ), TABLEB[PRODUCT] = EARLIER ( TABLEA[PRODUCT] ) )ProdMax = MAXX ( FILTER ( TABLEB, TABLEB[PRODUCT] = TABLEA[PRODUCT] ), TABLEB[Value] )
AlexisOlson
2 years agoSuper User
Try this:
ProdMax =
VAR _Prod = TABLEA[PRODUCT]
RETURN
CALCULATE ( MAX ( TABLEB[Value] ), TABLEB[PRODUCT] = _Prod )
Other variations:
ProdMax =
CALCULATE (
MAX ( TABLEB[Value] ),
TABLEB[PRODUCT] = EARLIER ( TABLEA[PRODUCT] )
)ProdMax =
MAXX (
FILTER ( TABLEB, TABLEB[PRODUCT] = TABLEA[PRODUCT] ),
TABLEB[Value]
)
JimT99
2 years agoHelper I
I tried your 2nd suggestion and it worked. Thank YOU!!
- Anonymous2 years agoNot applicable
You need to create a relationship between the two tables. In my response you can see how it is achieved. AlexisOlson measures work great but you need to get the relationship down for it all to be tied in together.