Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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)Sem título.png

 

 

 

1 ACCEPTED SOLUTION

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

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
v-jiascu-msft
Employee
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

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 !

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

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Hi,

This error has been corrected, but the return BLANK column and only the last two rows have (C <3.5 OR C> 7) should return "NOT" and the others as they should return "YES".

If you need I can send you a copy of my project.

Thanks so much !


column blank.png

 

Hi @Anonymous,

 

Please share the file. That would be the fast way to solve this issue. 

If you can make it public, please paste the download link here.

If you can't, please send me a private message through Message.

Anyway, please mask or delete the confidential parts.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @Anonymous,

 

This link needs permission. I have clicked Request. Please kindly approve. It's dalet****@gmail.com.

 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous,

 

There aren't any "AOD" in column Dados[COD_EQPMT]. That's why it's empty. You can see the result in the Data tab. 

Please add more details or delete this condition.

Logical_Conditions

 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Have in (Consulta2[COD_EQPMT_PRODC]) but Dados RELATED with Consulta1 . And Consulta1 RELATED with Consulta2 .

Consulta2 not RELATED with Dados.

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

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

It's working, thanks.

You helped me a lot.

But as I do add more   Dados[NOM_ABREV] = "305"  Dados[NOM_ABREV] = "306" Dados[NOM_ABREV] = "307" up to 320.
And each "304" "305" "306" "307" has different specifications
 
Anonymous
Not applicable

I got it

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.