Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
Here is the DAX code I have so far:
StatusPolitica = VAR SemanaAtual = WEEKNUM('PRINCIPAL'[DIA], 2) VAR SiglaAtual = 'PRINCIPAL'[SIGLA] VAR MotivoAtual = SELECTEDVALUE('PRINCIPAL'[MOTIVO]) VAR MarcaçõesSemana = 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çõesSemana >= 3, "Cumpriu", "Não Cumpriu" ) )
However, this code isn’t working as expected. It still shows “Cumpriu” or “Não Cumpriu” even when the “MOTIVO” column has “Afastamento” or “Férias”.
Could someone help me identify what I’m doing wrong or suggest a better approach?
Thank you!
Feel free to adjust the wording as needed. This should provide a clear and detailed explanation of your issue to the community. If you need any more help, let me know!
Solved! Go to Solution.
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.
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.
It's worked, thanks a lot!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
10 | |
6 |