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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Direct Query - Page Refresh

Hello, I am getting data form a server that is connected to a machine that makes parts, every X time, and I need to be able to have a counter on real time that can show me how many pcs have been built and cycle time, I have been using direct query for similar reports with page refresh of 1 minute, but for this query ower Bi dont let me use direct query 

 

let
Source = Sql.Databases("123"),

CompanyRecipeManagement01 = Source{[Name="456"]}[Data],

dbo_CustomerParts = CompanyRecipeManagement01{[Schema="dbo",Item="CustomerParts"]}[Data],

#"Added Custom" = Table.AddColumn(#"dbo_CustomerParts", "Machine", each "TR"),

#"Added Custom1" = Table.AddColumn(#"Added Custom", "BuildTime (min)", each Duration.TotalMinutes(([CompletedDate]-[StartDate]))),

#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Shift", each if (Time.Hour([CompletedDate]) >= 6) and (Time.Hour([CompletedDate]) < 14) then "1st" else if (Time.Hour([CompletedDate]) >= 14) and (Time.Hour([CompletedDate]) < 22) then "2nd" else "3rd"),

#"Added Custom3" = Table.AddColumn(#"Added Custom2", "CompanyCompletedDate", each if (Time.Hour([CompletedDate]) >= 22) then

//after 5pm then want to report for next day

DateTime.Date(Date.AddDays([CompletedDate] ,1))

else

//report the same day

DateTime.Date([CompletedDate])),

#"Sorted Rows" = Table.Sort(#"Added Custom3",{{"StartDate", Order.Descending}}),

#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),

#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1, Int64.Type),

#"Merged Queries" = Table.NestedJoin(#"Added Index1", {"Index"}, #"Added Index1", {"Index.1"}, "Added Index1", JoinKind.LeftOuter),

#"Expanded Added Index1" = Table.ExpandTableColumn(#"Merged Queries", "Added Index1", {"StartDate"}, {"Added Index1.StartDate"}),

#"Added Custom4" = Table.AddColumn(#"Expanded Added Index1", "CycleTime (min)", each if Duration.TotalMinutes([Added Index1.StartDate]-[StartDate]) > 2*[#"BuildTime (min)"]

then

""

else

Duration.TotalMinutes([Added Index1.StartDate]-[StartDate])),
#"Reordered Columns" = Table.ReorderColumns(#"Added Custom4",{"UniqueIdentifier", "CompletionStatusId", "CompanyPN", "ChassisNumber", "SequenceNumber", "RackPosition", "RackID", "From", "To", "IsJobCompleted", "StartDate", "CompletedDate", "COMPANYCompletedDate", "CompletionStatus", "JobRecipeSteps", "Machine", "BuildTime (min)", "Shift", "Index", "Index.1", "Added Index1.StartDate", "CycleTime (min)"}),
#"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"CycleTime (min)", type number}, {"Shift", type text}, {"CompletedDate", type date}, {"StartDate", type date}, {"BuildTime (min)", type number}, {"COMPANYCompletedDate", type date}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"CycleTime (min)"})
in
#"Removed Errors"

 

 

Can some one tell me how to getr a auto page refresh every minute without using Direct Query or how to transform the query to be able to use Direct Query.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Source = Sql.Databases("123"),

That won't work in the Power BI Service

 

Once you corrected that and specified the database you have to ask your capacity admin to allow the use of APR.  

 

Move all the query logic into SQL as a view or Stored Procedure to minimize the query time. Do as few transforms as possible in Power Query (unless they fold).

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Source = Sql.Databases("123"),

That won't work in the Power BI Service

 

Once you corrected that and specified the database you have to ask your capacity admin to allow the use of APR.  

 

Move all the query logic into SQL as a view or Stored Procedure to minimize the query time. Do as few transforms as possible in Power Query (unless they fold).

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors