Forum Discussion

abrother's avatar
abrother
Frequent Visitor
1 year ago
Solved

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 ...
  • Bibiano_Geraldo's avatar
    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
    )