Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Logical Conditions

Hi, i need some logical conditions, but i don't know hot to make it (syntax).

 

 

I need > IF (Dados[NOM_ABERV]) = "304" and (Dados[COD_EQPMT]) ="AOD" and RELATED(Consulta1[COD_TIPO_PRCES])=" F-F " and RELATED(Consulta1[C]) <4 OR  >7 ;  "NOT"; "YES";)

 

 IF (Dados[NOM_ABERV]) = "304" and (Dados[COD_EQPMT]) ="AOD" and RELATED(Consulta1[COD_TIPO_PRCES])=" F-P " and RELATED(Consulta1[C]) <3,5 OR  >7 ;  "NOT"; "YES";)

 

 IF (Dados[NOM_ABERV]) = "304" and (Dados[COD_EQPMT]) ="AOD" and RELATED(Consulta1[COD_TIPO_PRCES])=" F-F " and RELATED(Consulta1[C]) <3,5 OR  >7 ;  "NOT"; "YES";)

 

 IF (Dados[NOM_ABERV]) = "304" and (Dados[COD_EQPMT]) ="AOD" and RELATED(Consulta1[COD_TIPO_PRCES])=" F-P " and RELATED(Consulta1[C]) <10 OR  >99 ;  "NOT"; "YES";)

 

And I need to count how many results like "NOT"

 

I have more (Dados[NOM_ABREV]) not just "304" 

 (I'm Brazillian)

 

 

 

  • Hi Anonymous,

     

    Try this formula, please.

    Column 1 = 
    VAR COD_TIPO_PRCES =
        RELATED ( Consulta1[COD_TIPO_PRCES] )
    VAR c =
        RELATED ( Consulta1[C] )
    RETURN
        IF (
            Dados[NOM_ABREV] = "304"
                && CALCULATE(min('Consulta2'[COD_EQPMT_PRODC])) = "AOD" ,
            SWITCH (
                TRUE (),
                COD_TIPO_PRCES = "F-F"
                    && ( c < 3.5
                    || c > 7 ), "not",
                COD_TIPO_PRCES = "F-P"
                    && ( c < 4
                    || c > 7 ), "not",
               "yes"
            ),
            BLANK()
        )

    result

     

    Best Regards,

    Dale

12 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Anonymous,

     

    Try to add the formula below as a calculated column then it's easy to count the result.  Seems the condition 1 and 3, 2 and 4 can be integrated as one. Please check out.

    Column =
    VAR COD_TIPO_PRCES =
        RELATED ( Consulta1[COD_TIPO_PRCES] )
    VAR c =
        RELATED ( Consulta1[C] )
    RETURN
        IF (
            Dados[NOM_ABERV] = "304"
                && Dados[COD_EQPMT] = "AOD",
            SWITCH (
                TRUE (),
                COD_TIPO_PRCES = "F-F"
                    && ( c < 4
                    || c > 7 ), "not",
                COD_TIPO_PRCES = "F-P"
                    && ( c < 3.5
                    || c > 7 ), "not",
                COD_TIPO_PRCES = "F-F"
                    && ( c < 3.5
                    || c > 7 ), "not",
                COD_TIPO_PRCES = "F-P"
                    && ( c < 10
                    || c > 99 ), "not",
                "yes"
            ),
            BLANK ()
        )
    

    Best Regards,

    Dale

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-jiascu-msft 

       

       

      How would the formula convert so? DAX comparison operations are not supported for comparison of text values. Use a VALUE or FORMAT function to convert one of the values.

       

       

      Thanks !

      • v-jiascu-msft's avatar
        v-jiascu-msft
        Microsoft Employee

        Hi Anonymous,

         

        Please adjust these comparison values to your data types. Take the following comments as an example.

        Dados[NOM_ABERV] = "304" // if the type of Dados[NOM_ABERV] is TEXT.
        Dados[NOM_ABERV] = 304 // if the type of Dados[NOM_ABERV] is Number type.

         If the issue persists, please provide a sample file. Please mask the confidential parts first.

         

        Best Regards,

        Dale