Forum Discussion
abrother
1 year agoFrequent Visitor
Assign value to multiple rows based on rules and values from another column
Hi all, I have a difficult challenge I'm trying to overcome (at least difficult for me) in that I'm trying to create a new column that assigns a value to a set of rows (serial numbers all from a ...
- 1 year ago
Hi abrother ,
Create a new calculated column with the following DAX:
Primary Driver = VAR CurrentLot = 'Table'[Lot #] VAR HasSD1 = CALCULATE( COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Lot #]), 'Table'[Sub-Driver] = "SD1" ) VAR HasSD3 = CALCULATE( COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Lot #]), 'Table'[Sub-Driver] = "SD3" ) RETURN SWITCH( TRUE(), HasSD1 > 0, "PD1", HasSD3 > 0, "PD3", "Unknown" -- Default value if no rule matches )
Bibiano_Geraldo
Super User
1 year agoHi abrother ,
Create a new calculated column with the following DAX:
Primary Driver =
VAR CurrentLot = 'Table'[Lot #]
VAR HasSD1 = CALCULATE(
COUNTROWS('Table'),
ALLEXCEPT('Table', 'Table'[Lot #]),
'Table'[Sub-Driver] = "SD1"
)
VAR HasSD3 = CALCULATE(
COUNTROWS('Table'),
ALLEXCEPT('Table', 'Table'[Lot #]),
'Table'[Sub-Driver] = "SD3"
)
RETURN
SWITCH(
TRUE(),
HasSD1 > 0, "PD1",
HasSD3 > 0, "PD3",
"Unknown" -- Default value if no rule matches
)abrother
1 year agoFrequent Visitor
That worked! Thanks so much!