cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Convertir expresión Dax en función personalizada en Power Query

Hola queridos expertos comunitarios,

Tengo dos tablas que necesito anexar en Power Query. El problema es que una de esas tablas tiene una columna culculada que se crea con la siguiente expresión Dax:

id_city = IF(SEARCH ( "Dresden", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Augsburg", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Hannover", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "muenchen", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Leipzig", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Hamburg", CMAds[CM Campaign (CM Model)],, 0 ) = 0,  IF ( SEARCH ( "Wiesbaden", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "nuernberg", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Berlin", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "bochum", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "desden", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Sächsische-Zeitung", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "OneFootball", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "Spotify", CMAds[CM Campaign (CM Model)],, 0 ) = 0, IF ( SEARCH ( "akut recruiting", CMAds[CM Campaign (CM Model)],, 0 ) = 0, "14","1"),"1"),"1"),"1"),"6"),"7"),"1"),"10"),"11"), "5"),"2"),"4"), "3"), "8"),
    "6"
) 

Me preguntaba si hay una manera fácil de volver a crear esta función en la fase de transformación de datos (en Power Query), con el fin de tenerla disponible para anexar?

Muchas gracias de antemano!

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Convertir la expresión Dax en función personalizada en Power Query

Hey @Saro90,

por desgracia, no hay una manera fácil de transformar el DAX de una columna calculada en una columna personalizada en Power Query.

saludos

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Highlighted
Helper II
Helper II

Re: Convertir la expresión Dax en función personalizada en Power Query

Estimado @amitchandak @parry2k,

estará muy agradecido si pudiera echar un vistazo a esto.

Highlighted
Super User IX
Super User IX

Re: Convertir la expresión Dax en función personalizada en Power Query

@Saro90 , En la consulta de energía que tiene si entonces otra vez

y Text.Contains

https://docs.microsoft.com/en-us/powerquery-m/text-contains

Como

si Text.Contains([CM Campaign (CM Model)],"Dresden") y luego <> else <>



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support
Community Support

Re: Convertir la expresión Dax en función personalizada en Power Query

Hola, @Saro90

Puede crear una columna personalizada con los siguientes códigos en 'Editor de consultas' para ver si ayuda.

=
    if 
    Text.PositionOf([CM Campaign (CM Model)], "Dresden",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Dresden",Occurrence.First)=-1
    then if
    Text.PositionOf([CM Campaign (CM Model)], "Augsburg",Occurrence.First)=-1
    then if
    Text.PositionOf([CM Campaign (CM Model)], "Hannover",Occurrence.First)=-1
    then if
    Text.PositionOf([CM Campaign (CM Model)], "muenchen",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Leipzig",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Hamburg",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Wiesbaden",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "nuernberg",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Berlin",Occurrence.First)=-1                                                        
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "bochum",Occurrence.First)=-1                                   
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "desden",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Sächsische-Zeitung",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "OneFootball",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "Spotify",Occurrence.First)=-1
    then if 
    Text.PositionOf([CM Campaign (CM Model)], "akut recruiting",Occurrence.First)=-1
    then "14"
    else "1"
    else "1"
    else "1"
    else "1"
    else "6"
    else "7"
    else "1"
    else "10"
    else "11"
    else "5"
    else "2"
    else "4"
    else "3"
    else "8"
    else "6"
    

e1.png

Saludos

Allan

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Helpful resources

Announcements
Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Upcoming Events

Community Summit North America – Join Online!

Join this community-driven Power Platform digital event for unbiased support and problem-solving.

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Top Solution Authors