Forum Discussion

Dayna's avatar
Dayna
Icon for Helper V rankHelper V
7 years ago
Solved

Filter on two columns

Hello All,   I have a measure in my report where I want to do the following:   Count of all servers (ServerName) where there is a date entered within 'DateDrAvailable' and the flag for 'DisasterR...
  • AlB's avatar
    AlB
    7 years ago

    Hi  Dayna

    Yes, It's easier to do it in the query editor, or directly on the table; you can change the format in both ways. I did not mean to do it through the FORMAT function.

     

    The code you are showing now uses &.  Be careful because that is the concatenation operator. The logical AND, which is what you need here, is  &&

    So to start with, I'd update that:

     

    CumulCountAddedToDr = 
    CALCULATE (
        COUNT ( 'DR Server'[ServerName] ),
        FILTER (
            ALLSELECTED ( 'DR Server'),
            'DR Server'[DisasterRecoveryAvailable] = TRUE() && (format('DR Server'[DateDrAvailable],"DD/MM/YYYY") <= format(MAX ( MasterCalendar[Date]),"DD/MM/YYYY"))
        ))

    That might have actually caused the initial error since I am seeing that you didn't get the same error with the code that you show at the very beginning, and hat has the exact same comparison as the code you say throws the error (in blue below)

     

    CumulCountAddedToDr = 
    CALCULATE (
        COUNT ( 'DR Server'[ServerName] ),
        FILTER (
            ALLSELECTED ( 'DR Server'),
            'DR Server'[DateDrAvailable] <= MAX ( MasterCalendar[Date]) 
        )
    ) 

     

    Was 'DR Server'[DateDrAvailable] already of type date? I suspect so