Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CraigBlackman
Helper III
Helper III

Column reference to 'wo_built_datetime' in table 'works_order' cannot be used with a variation 'Date

Hi,

 

I am getting this error in direct query with the following formula. I have tried both column and measure with the same issue. It works fine if using a import template opposed to directquery.

 

Defined_Date =
IF (
TIMEVALUE ( works_order[Time] ) >= TIMEVALUE ( "07:00:00" )
&& TIMEVALUE ( works_order[Time] ) <= TIMEVALUE ( "23:59:59" ),
works_order[wo_built_datetime].[Date],
IF (
TIMEVALUE ( works_order[Time] ) < TIMEVALUE ( "07:00:00" )
&& CONTAINS (
works_order,
works_order[wo_built_datetime].[Date], works_order[wo_built_datetime].[Date] - 1
),
works_order[wo_built_datetime].[Date] - 1,
works_order[wo_built_datetime].[Date]
)
)

 

Not sure why this would be?

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @CraigBlackman,

 

Since there are some of limitions to use dax at directquery mode, you can use power query to check the value.

 

Below is the sample.

 

Table.

Capture.PNG

 

Formula:

 

    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom", each 
        if Time.From([USDate]) >= #time(7,0,0) and Time.From([USDate]) <= #time(23,59,59) 
        then [USDate] 
        else if Time.From([USDate]) < #time(7,0,0) and List.Contains(Table.SelectColumns(Table.TransformColumnTypes(#"Changed Type",{{"USDate", type date}}),"USDate")[USDate],Date.AddDays(Date.From([USDate]), -1))
        then Date.AddDays(Date.From([USDate]), -1) 
        else [USDate])

 

Result:

Capture2.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.