Forum Discussion
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
- AnonymousNot 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
) - AnonymousNot 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
- AnonymousNot applicable
I am using direct query and this code says its not supported in Direct query mode. Requirement is to have a direct query. any suggestions for a walkaround?
- AnonymousNot applicable
HI Anonymous,
Perhaps you can try to use the t-SQL statement to write a t-SQL query to add the custom calculation column to the result table.
You can click on the advanced options -> SQL statement to find it:
Power Query SQL Server connector - Power Query | Microsoft Learn
Import data from a database using native database query - Power Query | Microsoft Learn
Regards,Xiaoxin Sheng