Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

How can i write this query in power query

I have this DAX query that i need to write in Power query, the problem is i am using a direct query and its not taking most syntax / functions. anyone in a  possible to help with how i can write this in power query that is using direct query?

--the error mesage says literal expected  here 'Tasks'

IF (
( NOT ( ISBLANK ( 'Tasks'[ACT_START_DATE] ) ) && ISBLANK ( 'Tasks'[ACT_END_DATE] ) )
|| 'Tasks'[ACT_START_DATE]
<= TODAY () + 2,
'Tasks'[ACT_END_DATE] - 1
)

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    i have made some changes  to the query into this one but now it says i need parenthesis  after 2, i tried but its not taking it. 

    if (
    ( NOT ( ISBLANK ([ACT_START_DATE] ) ) and ISBLANK ( [ACT_END_DATE] ) )
    or [ACT_START_DATE]
    <= TODAY () + 2, [FINISH_DATE] - 1
    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Anonymous,

    For the Dax formula with some simple if statements, it is possible to convert them to m query formulas. You can refer to the following formula to create a new column on the query table side:

        Addcolumn = Table.AddColumn(
            Source,
            "Custom",
            each
                if ([ACT_START_DATE] <> null and [ACT_END_DATE] = null)
                or [ACT_START_DATE] <= Date.AddDays(Date.From(DateTime.LocalNow()), -2) 
                then
                    Date.AddDays([ACT_END_DATE], -1)
                else
                    [ACT_END_DATE]
        )

    Regards,

    Xiaoxin Sheng