<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic DAX: Conditional in Calculated Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4264424#M169015</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m working on a calculated column in Power BI and need some help with DAX. Here is what I’m trying to achieve:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have a column called “MOTIVO” with values like “Afastamento”, “Ausência”, “Falta”, “Férias”, and “Presença”.&lt;/LI&gt;&lt;LI&gt;I have another column called “CONTADOR” with values “0” and “1”.&lt;/LI&gt;&lt;LI&gt;I need to create a calculated column that:&lt;UL&gt;&lt;LI&gt;Shows “Cumpriu” if the value “1” appears 3 times or more in the “CONTADOR” column within the same week.&lt;/LI&gt;&lt;LI&gt;Shows “Não Cumpriu” if the value “1” appears less than 3 times in the “CONTADOR” column within the same week.&lt;/LI&gt;&lt;LI&gt;Shows “Afastamento” or “Férias” if the “MOTIVO” column has these values, regardless of the “CONTADOR” values.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here is the DAX code I have so far:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;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 &amp;amp;&amp;amp;
            'PRINCIPAL'[SIGLA] = SiglaAtual &amp;amp;&amp;amp;
            'PRINCIPAL'[CONTADOR] = 1
        )
    )

RETURN
IF(
    MotivoAtual IN {"Afastamento", "Férias"},
    MotivoAtual,
    IF(
        MarcaçõesSemana &amp;gt;= 3,
        "Cumpriu",
        "Não Cumpriu"
    )
)&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;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”.&lt;/P&gt;&lt;P&gt;Could someone help me identify what I’m doing wrong or suggest a better approach?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;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!&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2024 18:30:20 GMT</pubDate>
    <dc:creator>amaral_diego</dc:creator>
    <dc:date>2024-10-30T18:30:20Z</dc:date>
    <item>
      <title>DAX: Conditional in Calculated Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4264424#M169015</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m working on a calculated column in Power BI and need some help with DAX. Here is what I’m trying to achieve:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have a column called “MOTIVO” with values like “Afastamento”, “Ausência”, “Falta”, “Férias”, and “Presença”.&lt;/LI&gt;&lt;LI&gt;I have another column called “CONTADOR” with values “0” and “1”.&lt;/LI&gt;&lt;LI&gt;I need to create a calculated column that:&lt;UL&gt;&lt;LI&gt;Shows “Cumpriu” if the value “1” appears 3 times or more in the “CONTADOR” column within the same week.&lt;/LI&gt;&lt;LI&gt;Shows “Não Cumpriu” if the value “1” appears less than 3 times in the “CONTADOR” column within the same week.&lt;/LI&gt;&lt;LI&gt;Shows “Afastamento” or “Férias” if the “MOTIVO” column has these values, regardless of the “CONTADOR” values.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here is the DAX code I have so far:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;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 &amp;amp;&amp;amp;
            'PRINCIPAL'[SIGLA] = SiglaAtual &amp;amp;&amp;amp;
            'PRINCIPAL'[CONTADOR] = 1
        )
    )

RETURN
IF(
    MotivoAtual IN {"Afastamento", "Férias"},
    MotivoAtual,
    IF(
        MarcaçõesSemana &amp;gt;= 3,
        "Cumpriu",
        "Não Cumpriu"
    )
)&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;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”.&lt;/P&gt;&lt;P&gt;Could someone help me identify what I’m doing wrong or suggest a better approach?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;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!&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 18:30:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4264424#M169015</guid>
      <dc:creator>amaral_diego</dc:creator>
      <dc:date>2024-10-30T18:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Conditional in Calculated Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4264686#M169024</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="797318" data-lia-user-login="amaral_diego" class="lia-mention lia-mention-user"&gt;amaral_diego&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this calculation column.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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 &amp;amp;&amp;amp;
            'PRINCIPAL'[SIGLA] = SiglaAtual &amp;amp;&amp;amp;
            'PRINCIPAL'[CONTADOR] = 1
        )
    )

RETURN
IF(
    MotivoAtual IN {"Afastamento", "Férias"},
    MotivoAtual,
    IF(
        Marca &amp;gt;= 3,
        "Cumpriu",
        "Não Cumpriu"
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your Current Period does not refer to this, please clarify in a follow-up reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Clara Gong&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 01:44:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4264686#M169024</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-31T01:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Conditional in Calculated Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4265519#M169051</link>
      <description>&lt;P&gt;It's worked, thanks a lot!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 12:15:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Conditional-in-Calculated-Column/m-p/4265519#M169051</guid>
      <dc:creator>amaral_diego</dc:creator>
      <dc:date>2024-10-31T12:15:47Z</dc:date>
    </item>
  </channel>
</rss>

