Forum Discussion

amaral_diego's avatar
amaral_diego
Helper II
1 year ago
Solved

DAX: Conditional in Calculated Column

Hi everyone, I’m working on a calculated column in Power BI and need some help with DAX. Here is what I’m trying to achieve: I have a column called “MOTIVO” with values like “Afastamento”, “Ausênc...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi amaral_diego ,

     

    You can try this calculation column.

    StatusPolitica = 
    VAR SemanaAtual = WEEKNUM('PRINCIPAL'[DIA], 2)
    VAR SiglaAtual = 'PRINCIPAL'[SIGLA]
    VAR MotivoAtual = 'PRINCIPAL'[MOTIVO]
    VAR Marca = 
        CALCULATE(
            COUNTROWS('PRINCIPAL'),
            FILTER(
                'PRINCIPAL',
                WEEKNUM('PRINCIPAL'[DIA], 2) = SemanaAtual &&
                'PRINCIPAL'[SIGLA] = SiglaAtual &&
                'PRINCIPAL'[CONTADOR] = 1
            )
        )
    
    RETURN
    IF(
        MotivoAtual IN {"Afastamento", "Férias"},
        MotivoAtual,
        IF(
            Marca >= 3,
            "Cumpriu",
            "Não Cumpriu"
        )
    )

     

    If your Current Period does not refer to this, please clarify in a follow-up reply.

     

    Best Regards,

    Clara Gong

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.