Forum Discussion

AKARSEVGI's avatar
AKARSEVGI
Icon for Helper I rankHelper I
4 years ago

POWER QUERY IF

How can I rewrite this -------
IF(( ("PROJE NO" LIKE '%.S.%' OR "PROJE NO" LIKE '%.s.%' OR "PROJE NO" NOT LIKE '%.%' OR "PROJE NO" IS NULL ) AND "SERVİS TANIM" IS NULL AND "SERVİS TİPİ" IS NULL) THEN [COUNTRY]&"é"&900, ELSE IF[COUNTRY]&"é"&[SALDEPT])--------- in power query with custom column formulas?

3 Replies

  • Power Query uses small letters

     

    IF => if

    IS NULL => = null

    AND => and

     

    etc.

     

    Power Query does not have a concept of "LIKE" - you need to write that manually.

  • Hey AKARSEVGI !

     

    You can use the 'not Text.Contains' to check the values.  Create a new column to recieve checked value.

    The basis is: 
    Table.AddColumn(#"Added Conditional Column", "Custom", each if not Text.Contains([Status], "S.") then "Country" else if not Text.Contains([Status], "s.") then "Country" else "Another information")

     

    ** If this post helps, please consider accept as solution to help other members find it more quickly.

    Regards
    Marcel Magalhaes

  • Hi, AKARSEVGI ;

    If a dax.

    column =
    IF (
        (
            (
                CONTAINSSTRING ( [PROJE NO], ".S." ) || CONTAINSSTRING ( [PROJE NO], ".s." )
                    || CONTAINSSTRING ( [PROJE NO], "." )
                    || [PROJE NO] = BLANK ()
            )
                && [SERVİS TANIM] = BLANK ()
                && [SERVİS TİPİ] = BLANK ()
        ),
        [COUNTRY] & "é" & "900",
        [COUNTRY] & "é" & [SALDEPT]
    )

    If in power query.

    =if  (Text.Contains([PROJE NO],".s.") || Text.Contains([PROJE NO],".S.")  || Text.Contains([PROJE NO],".")  
    || [PROJE NO] = null )
    && [SERVİS TANIM] = null
    && [SERVİS TİPİ] = null 
     then  [COUNTRY] & "é" & "900" 
     else [COUNTRY] & "é" & [SALDEPT]

    Best Regards,