Forum Discussion
Syndicate_Admin
4 years agoAdministrator
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...
- 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 )
Syndicate_Admin
4 years agoAdministrator
Eso es correcto, la respuesta correcta sería 4, pensé que he cambiado de año.
Espero con ansias cómo harías esto con dax.
Syndicate_Admin
4 years agoAdministrator
@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
)