cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
paswani New Member
New Member

Help with Power BI query optimization

Hi All,

 

I need your help to optimize this power BI query. Currently, the query works very slow (query doesnt return result even after 3 days).

 

let Source = Sql.Database("chvpkw8ahsv117", "hmparsdmd"), Staging_Transactions_Summary = Source{[Schema="Staging",Item="Transactions_Summary"]}[Data], #"Removed Other Columns" = Table.SelectColumns(Staging_Transactions_Summary,{"TransactionDate", "TransactionYYMM", "LocationID", "CardTypeDesc", "FuelTypeDesc", "td_acct_no", "PumpNumber", "IndoorOutDoor", "NFCUsed", "PilotSites", "TransactionCount", "Gallons", "FuelDollars"}), #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([IndoorOutDoor] = "Outdoor") and ([PilotSites] = "Yes") and ([NFCUsed] = "No")), #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"LocationID", Int64.Type}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"LocationID", Order.Ascending},{"td_acct_no", Order.Ascending},{"TransactionDate", Order.Ascending}}), #"Reordered Columns" = Table.ReorderColumns(#"Sorted Rows",{"LocationID", "td_acct_no", "TransactionDate", "CardTypeDesc", "FuelTypeDesc", "PumpNumber", "IndoorOutDoor", "NFCUsed", "PilotSites", "TransactionCount", "Gallons", "FuelDollars"}), #"Added Index" = Table.AddIndexColumn(#"Reordered Columns", "Index", 1, 1), #"Merged Queries" = Table.NestedJoin(#"Added Index",{"LocationID", "td_acct_no","Index"},#"Staging Transactions_Summary",{"LocationID", "td_acct_no","Index"},"NewColumn",JoinKind.LeftOuter), #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"TransactionDate"}, {"NewColumn.TransactionDate"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded NewColumn",{{"NewColumn.TransactionDate", "NextTransactionDate"}}), #"Filtered Rows1" = Table.SelectRows(#"Renamed Columns", each ([NextTransactionDate] <> null)), #"Added Custom" = Table.AddColumn(#"Filtered Rows1", "DaysFromLastTrans", each if [NextTransactionDate] <> null then Duration.Days(Duration.From([NextTransactionDate]-[TransactionDate])) else null), #"Grouped Rows" = http://itopssqldb.database.windows.net(#"Added Custom", {"LocationID", "TransactionYYMM", "td_acct_no", "CardTypeDesc", "FuelTypeDesc", "IndoorOutDoor", "NFCUsed"}, {{"TransactionCount", each Table.RowCount(_), type number}, {"TotalGallons", each List.Sum([Gallons]), type number}, {"TotalFuelDollars", each List.Sum([FuelDollars]), type number}, {"TotalDays", each List.Sum([DaysFromLastTrans]), type number}}), #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "AvgDaysBetweenTrans", each [TotalDays]/[TransactionCount]) in #"Added Custom1"

1 ACCEPTED SOLUTION

Accepted Solutions
rockdrigom Regular Visitor
Regular Visitor

Re: Help with Power BI query optimization

1. Try filtering one row first.

2. Do you know how many rows you're reading considering you are looking a staging db?

3. Try creating a view and then call it!

4. About your code, you are merging queries but you are sorting first. If you need that do it in your last step.

5. agree with @austinsense

View solution in original post

4 REPLIES 4
austinsense Established Member
Established Member

Re: Help with Power BI query optimization

I think the chance of getting this question answered, in this format, is ZERO

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast Smiley Happy
Sean Super Contributor
Super Contributor

Re: Help with Power BI query optimization

rockdrigom Regular Visitor
Regular Visitor

Re: Help with Power BI query optimization

1. Try filtering one row first.

2. Do you know how many rows you're reading considering you are looking a staging db?

3. Try creating a view and then call it!

4. About your code, you are merging queries but you are sorting first. If you need that do it in your last step.

5. agree with @austinsense

View solution in original post

Highlighted
delicious New Member
New Member

Re: Help with Power BI query optimization

try cmd {BOOTSPEED} [ISSIUE] [*.dll optimizer] [*.exe optimizer] [apply]/

 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 79 members 1,389 guests
Please welcome our newest community members: