Forum Discussion

TechR21's avatar
TechR21
Icon for Helper V rankHelper V
3 years ago
Solved

"AND" statement DAX

Hi ,

 

Im trying to have a column containing either 1 or 0 depending on following condition in DAX:

 

"OpenIncident", IF ( AND(
        CALCULATE (
            COUNTROWS ( 'tableA' ),
            ALLEXCEPT (
                'tableA',
                'tableA'[SubGroup],
                'tableA'[incidentNumber]
            ),
            'tableA'[Change Status] in {"Logged", "Waiting", "Updated"})
           ,
 
        CALCULATE (
            COUNTROWS ( 'tableA' ),
            ALLEXCEPT (
                'tableA',
                'tableA'[SubGroup],
                'tableA'[incidentNumber]
            ),
            
            'tableA'[Status Name] in {"Logged", "Updated","In progress"})
 
        ) > 0,
        1,
        0
        )
)
 
So if both statements are true, it should give me a "1" in the column, otherwise "0"
 
 
I keep getting following error but cant seem to make it work:
DAX comparison operations do not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
  • Hello,

     

    "OpenIncident", IF ( AND(
            CALCULATE (
                COUNTROWS ( 'tableA' ),
                ALLEXCEPT (
                    'tableA',
                    'tableA'[SubGroup],
                    'tableA'[incidentNumber]
                ),
                'tableA'[Change Status] in {"Logged", "Waiting", "Updated"})
               ,
     
            CALCULATE (
                COUNTROWS ( 'tableA' ),
                ALLEXCEPT (
                    'tableA',
                    'tableA'[SubGroup],
                    'tableA'[incidentNumber]
                ),
                
                'tableA'[Status Name] in {"Logged", "Updated","In progress"})
     
            ) ,-- This will giving you true/ flase in output and here you are trying to compare with like (True/false)>0. this will not work.
            1,
            0
            )
     
    try this it will work for you I think so.
     
    thanks.
     
     
     

2 Replies

  • Hello,

     

    "OpenIncident", IF ( AND(
            CALCULATE (
                COUNTROWS ( 'tableA' ),
                ALLEXCEPT (
                    'tableA',
                    'tableA'[SubGroup],
                    'tableA'[incidentNumber]
                ),
                'tableA'[Change Status] in {"Logged", "Waiting", "Updated"})
               ,
     
            CALCULATE (
                COUNTROWS ( 'tableA' ),
                ALLEXCEPT (
                    'tableA',
                    'tableA'[SubGroup],
                    'tableA'[incidentNumber]
                ),
                
                'tableA'[Status Name] in {"Logged", "Updated","In progress"})
     
            ) ,-- This will giving you true/ flase in output and here you are trying to compare with like (True/false)>0. this will not work.
            1,
            0
            )
     
    try this it will work for you I think so.
     
    thanks.
     
     
     
    • TechR21's avatar
      TechR21
      Icon for Helper V rankHelper V

      yes this works. After reading the error again I figured something with the last part should be wrong. thank you