Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago
Solved

convertir SQL(case) a Dax

Hola chicos, Tengo esta consulta en sql que estoy tratando de hacer una medida en powerbi pero tengo problemas, Consulta SQL: SELECCIONE COUNT (DISTINCT(ID)) - COUNT( DISTINCT (caso cuan...
  • Syndicate_Admin's avatar
    Syndicate_Admin
    4 years ago

    @sun-sboyanapall ¿Puedes probar esta medida?

    Measure =
    CALCULATE (
        DISTINCTCOUNT ( tbl[ID] ),
        VAR _base =
            FILTER (
                tbl,
                tbl[TransactionDate] <> BLANK ()
                    && tbl[ConvertedDate] <> BLANK ()
                    && tbl[Date_of_Last_Status_Change__c] <> BLANK ()
            )
        VAR _left =
            FILTER ( tbl, tbl[ID] <> BLANK () )
        VAR _join =
            EXCEPT (
                _left,
                FILTER (
                    _base,
                    MONTH ( COALESCE ( tbl[ConvertedDate], tbl[Date_of_Last_Status_Change__c] ) )
                        <> MONTH ( tbl[TransactionDate] )
                        && YEAR ( COALESCE ( tbl[ConvertedDate], tbl[Date_of_Last_Status_Change__c] ) )
                            <> YEAR ( tbl[TransactionDate] )
                )
            )
        RETURN
            _join
    )